newlib fails to build if the `clang` binary doesn't exist
On my workstation, I installed clang-7 via the llvm apt repository (https://apt.llvm.org/). As such, I have a clang-7 binary. clang is missing.
I noticed that the toolchain file checks for the CLANG_BIN environment variable so I exported it before re-running cmake.
The build however fails because newlib is hardcoded to use the clang binary.
I fixed the build with a small change. I'd submit a pull request, but I can't seem to sign the CLA (I'm getting an "something went wrong" error when submitting the form). So feel free to take this diff and adjust as you see fit:
diff --git a/scripts/cmake/depends/newlib.cmake b/scripts/cmake/depends/newlib.cmake
index 6db8b94c..3366d5bf 100644
--- a/scripts/cmake/depends/newlib.cmake
+++ b/scripts/cmake/depends/newlib.cmake
@@ -28,8 +28,14 @@ if((ENABLE_BUILD_VMM OR ENABLE_BUILD_TEST) AND NOT WIN32)
URL_MD5 ${NEWLIB_URL_MD5}
)
- set(CC_FOR_TARGET clang)
- set(CXX_FOR_TARGET clang)
+ if(DEFINED ENV{CLANG_BIN})
+ set(CLANG_BIN $ENV{CLANG_BIN})
+ else()
+ find_program(CLANG_BIN clang)
+ endif()
+
+ set(CC_FOR_TARGET ${CLANG_BIN})
+ set(CXX_FOR_TARGET ${CLANG_BIN})
set(AR_FOR_TARGET ar)
set(AS_FOR_TARGET as)
@rianquinn I havent heard of this CLA bug..do you know how to fix it?
I haven't either. @ihalip Have you tried recently? It is possible something was wrong with their servers.
Yes, something is definitely wrong with their servers - I'm getting an HTTP 500 error when submitting the form. Clearing cookies/disabling uBlock don't help.
I was unable to sign it yesterday as well, but I can today. Try again now.
As an FYI, now that clang 8 is out, I will likely test this as well on my end to ensure that we can select a compiler across the board. I'm not sure the patch above is enough, so I want to test just to be sure.
This should be fixed. If it isn't, please feel free to open this again