[Bug 261379] clang 10.0 fails to cross-compile against target x86_64-unknown-freebsd7

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 21 Jan 2022 15:41:03 UTC

            Bug ID: 261379
           Summary: clang 10.0 fails to cross-compile against target
           Product: Base System
           Version: 12.3-RELEASE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: hayatelee@gmail.com

Background: We need to backport a tools built with clang on FreeBSD-12 to

1. Download sysroot from
2. untar the base and fix the symlinks
3. create a simple main.c with the following content

#include <stdio.h>

int main() {
    printf("hello world\n");
    return 0;

4. build it with
clang -target x86_64-unknown-freebsd7 --sysroot=/path/to/sysroot -fuse-ld=lld
-v main.c

5. linker error:
FreeBSD clang version 10.0.1 (git@github.com:llvm/llvm-project.git
Target: x86_64-unknown-freebsd7
Thread model: posix
InstalledDir: /usr/bin
 "/usr/bin/clang" -cc1 -triple x86_64-unknown-freebsd7 -emit-obj -mrelax-all
-disable-free -disable-llvm-verifier -discard-value-names -main-file-name
main.c -mrelocation-model static -mthread-model posix -mframe-pointer=all
-fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables
-fno-use-init-array -target-cpu x86-64 -dwarf-column-info
-fno-split-dwarf-inlining -debugger-tuning=gdb -v -resource-dir
/usr/lib/clang/10.0.1 -isysroot /path/to/sysroot -fdebug-compilation-dir
/usr/home/test -ferror-limit 19 -fmessage-length 117 -fgnuc-version=4.2.1
-fobjc-runtime=gnustep -fdiagnostics-show-option -fcolor-diagnostics -faddrsig
-o /tmp/main-ca9b0b.o -x c main.c
clang -cc1 version 10.0.1 based upon LLVM 10.0.1 default target
#include "..." search starts here:
#include <...> search starts here:
End of search list.
 "/usr/bin/ld.lld" --sysroot=/home/vagrant/farm_tree --eh-frame-hdr
-dynamic-linker /libexec/ld-elf.so.1 --enable-new-dtags -o a.out
/home/vagrant/farm_tree/usr/lib/crt1.o /home/vagrant/farm_tree/usr/lib/crti.o
/home/vagrant/farm_tree/usr/lib/crtbegin.o -L/home/vagrant/farm_tree/usr/lib
/tmp/main-ca9b0b.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc
--as-needed -lgcc_s --no-as-needed /home/vagrant/farm_tree/usr/lib/crtend.o
ld.lld: error: .eh_frame: relocation is not in any piece
clang: error: linker command failed with exit code 1 (use -v to see invocation)

ps: it seems this is a regression, because on FreeBSD-11 with clang 6.0, the
above works

You are receiving this mail because:
You are the assignee for the bug.