-
Notifications
You must be signed in to change notification settings - Fork 119
Fix build with clang by using llvm-ar #607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
3005f7f
to
bb58add
Compare
Ensure that llvm-ar and other LLVM tools from version 18 are available in the PATH during CI builds. Without this, only the versioned binaries (e.g. llvm-ar-18) are found, which can cause build failures when unversioned tool names are expected.
When building with clang and RV32F enabled, linking fails with undefined references to SoftFloat functions. For example: $ make CC=clang-18 /usr/bin/ld: /tmp/lto-llvm-28abb9.o: in function `do_fmadds': emulate.c:(.text.do_fmadds+0x3c): undefined reference to `f32_mulAdd' /usr/bin/ld: /tmp/lto-llvm-28abb9.o: in function `do_fadds': emulate.c:(.text.do_fadds+0x31): undefined reference to `f32_add' This happens because GNU ar cannot correctly archive objects compiled with clang. Switch to llvm-ar when CC is clang, ensuring the SoftFloat library is archived correctly and the build succeeds.
bb58add
to
7d2b787
Compare
I ran |
I only ran make CC=clang-18 and hit the build error.
In addition, I added the following lines in the Makefile to confirm toolchain versions: $(CC) --version
$(AR) --version The output was:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I couldn’t reproduce the issue, but the fix looks correct to me.
Thank @visitorckw for contributing! |
When building with clang and RV32F enabled, linking fails with undefined references to SoftFloat functions. For example:
$ make CC=clang-18
/usr/bin/ld: /tmp/lto-llvm-28abb9.o: in function
do_fmadds': emulate.c:(.text.do_fmadds+0x3c): undefined reference to
f32_mulAdd'/usr/bin/ld: /tmp/lto-llvm-28abb9.o: in function
do_fadds': emulate.c:(.text.do_fadds+0x31): undefined reference to
f32_add'This happens because GNU ar cannot correctly archive objects compiled with clang. Switch to llvm-ar when CC is clang, ensuring the SoftFloat library is archived correctly and the build succeeds.