[llvm-bugs] [Bug 37437] New: clang generic ELF link command forwards to gcc

via llvm-bugs llvm-bugs at lists.llvm.org
Sun May 13 06:39:29 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=37437

            Bug ID: 37437
           Summary: clang generic ELF link command forwards to gcc
           Product: clang
           Version: 6.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Driver
          Assignee: unassignedclangbugs at nondot.org
          Reporter: janhenrikm at yahoo.de
                CC: llvm-bugs at lists.llvm.org

Linking an executable with target i386-none-elf calls to gcc instead of
directly calling a linker

1) touch test.c
2) clang -target i386-none-elf -o test.o -c test.c
3) clang -target i386-none-elf -o test test.o -v

clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)
Target: i386-none--elf
Thread model: posix
InstalledDir: /usr/bin
 "/usr/bin/gcc" -v -m32 -o test test.o
[...]
clang: error: linker (via gcc) command failed with exit code 1 (use -v to see
invocation)

Clang forwards the link command to gcc resulting in the loss of the target
information.

Instead clang could invoke the linker directly and supply the needed flags for
the linker to infer a target.

Tested using
clang version 3.8.0-2ubuntu4 on ubuntu
clang version 5.0.2-svn328729-1~exp1~20180509124008.99 on ubuntu
clang version 6.0.0 on macOS
Apple clang version 8.0.0 on macOS

This unexpected behaviour happens for all generic elf targets because the
Generic_ELF driver defaults to the tools::gcc::Linker instead of the
tools::gnutools::linker like the linux driver.

As a result linking for a different architecture than the host results in
linker errors.

The desired behaviour can be achieved using a i386-linux-elf target and using
-nostdlib.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180513/4fe913fc/attachment.html>


More information about the llvm-bugs mailing list