Re: Cross compiled GCC wrongly builds dynamic executables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Aug 20, 2016 at 12:46 AM, Alastair Hughes
<hobbitalastair@xxxxxxxxxx> wrote:
>> On Fri, Aug 19, 2016 at 1:35 PM, Alastair Hughes
>> <hobbitalastair@xxxxxxxxxx> wrote:
>>
>>> Hi all!
>>>
>>> I am cross compiling GCC to produce a compiler to run on the target machine (ie --build="${_local_triplet}" --host="${_target_triplet}" --target="${_target_triplet}"). The target system is a simple *statically linked* musl-libc based system.
>>> After a recent upgrade to binutils 2.27, the cross compiled cc1 and cc1plus executables where generated as *dynamically linked*, due to a combination of the -rdynamic flag to GCC during the build, and a recent change in binutils (https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=bf89386a862ace008f0152bca8bddf996d3993c8, https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=9c1d7a087682074d585253ad38719ec2363eb2b7 - the first commit being problematic).
>>>
>>> I am unsure as to whether this is an issue with the GCC build, something that I have configured, or a bug in binutils. Why is -rdynamic being passed when building cc1 and cc1plus? Is that what should be happening, a bug, or a problem with how I have configured GCC?
>>>
>>> I've also CC'd the committer in case he can explain.
>>
>> It is for GCC plugin. Does your compiler support GCC plugin?
>> If not, you should configure your GCC with --disable-plugin.
>>
>> --
>> H.J.
>
> No, there is no dynamic linker on the target - your suggestion works, thanks.
>
> I'm a bit surprised that the ld creates dynamically linked executables in the first place, since they cannot ever run at runtime (missing the dynamic loader) and there is no dynamic libraries to link against. What is the use case for that? Is there some way to stop ld from ever creating dynamically linked executables?
>
> Alastair Hughes

For Linux/x86 target, there are

#define GNU_USER_TARGET_LINK_SPEC                                  \
                  "%{" SPEC_64 ":-m " GNU_USER_LINK_EMULATION64 "} \
                   %{" SPEC_32 ":-m " GNU_USER_LINK_EMULATION32 "} \
                   %{" SPEC_X32 ":-m " GNU_USER_LINK_EMULATIONX32 "} \
  %{shared:-shared} \
  %{!shared: \
    %{!static: \
      %{rdynamic:-export-dynamic} \
      %{" SPEC_32 ":-dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "} \
      %{" SPEC_64 ":-dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "} \
      %{" SPEC_X32 ":-dynamic-linker " GNU_USER_DYNAMIC_LINKERX32 "}} \
    %{static:-static}}"

It assumes that -static is used to create static executable, in which
case -rdynamic is ignored.  Apparently, in your case, -static isn't used
when creating static executable.  Please double check if your target
is properly supported by GCC.


-- 
H.J.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux