Re: Compiling Xen on FreeBSD using clang ...

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Sun, 19 Oct 2014 21:27:31 +0200
On 19 Oct 2014, at 18:34, Matthew Grooms <mgrooms_at_shrew.net> wrote:
> As most of you are probably aware, Roger at Citrix R&D has been doing some incredible work to bring PVH domU/dom0 support to FreeBSD. There has also been an effort by other Xen developers to get the software to compile using clang. While most of these attempts appear to be on Linux platforms targeting arm processors, the FreeBSD version of binutils is quite a bit older. Clang still can't parse all of the assembly that Xen requires, so unfortunately the -no-integrated-as option has to be used in several cases.

What kind of assembly is that?  And are you using clang 3.4.1 from base?


> Which brings me to my question, is there a way to ask clang to use the ports version of binutils when -no-integrated-as is passed to clang? The version of 'as' in base fails to compile such as ...
> 
> /tmp/misc-bf1339.s: Assembler messages:
> /tmp/misc-bf1339.s:375: Error: unknown pseudo-op: `.cfi_sections'

Yes, binutils in base is forever stuck at version 2.17.50, which is
ancient by by now.


> If /usr/local/bin/as is symlinked to /usr/bin/as, the compile completes but I assume there is a better way to tell clang where the external as binary is when -no-integrated-as is invoked. I've googled a bunch but came up empty handed so far. I thought it would be worth asking here in case someone has already run across this problem and had more insight.

Yes, just pass -B/usr/local/bin on the command line.  Note that this
will make it search for *all* external tools in /usr/local/bin, e.g.
ld will also be run from there.  For example:

$ clang -v -no-integrated-as -B/usr/local/bin hello-world.c -o hello-world
FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
Target: i386-unknown-freebsd11.0
Thread model: posix
Selected GCC installation:
 "/usr/bin/clang" -cc1 -triple i386-unknown-freebsd11.0 -S -disable-free -main-file-name hello-world.c -mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases -target-cpu i486 -v -resource-dir /usr/bin/../lib/clang/3.4.1 -fno-dwarf-directory-asm -fdebug-compilation-dir /share/dim/src/misc -ferror-limit 19 -fmessage-length 297 -mstackrealign -fobjc-runtime=gnustep -fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o /home/dim/tmp/hello-world-410124.s -x c hello-world.c
clang -cc1 version 3.4.1 based upon LLVM 3.4.1 default target i386-unknown-freebsd11.0
ignoring nonexistent directory "/usr/bin/../lib/clang/3.4.1/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/clang/3.4.1
 /usr/include
End of search list.
 "/usr/local/bin/as" --32 -o /home/dim/tmp/hello-world-288694.o /home/dim/tmp/hello-world-410124.s
 "/usr/local/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --hash-style=both --enable-new-dtags -m elf_i386_fbsd -o hello-world /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib /home/dim/tmp/hello-world-288694.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o

-Dimitry
Received on Sun Oct 19 2014 - 17:27:36 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:53 UTC