hypervisor icon indicating copy to clipboard operation
hypervisor copied to clipboard

newlib fails to build if the `clang` binary doesn't exist

Open ihalip opened this issue 7 years ago • 6 comments

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)

ihalip avatar Mar 19 '19 21:03 ihalip

@rianquinn I havent heard of this CLA bug..do you know how to fix it?

cjams avatar Mar 19 '19 22:03 cjams

I haven't either. @ihalip Have you tried recently? It is possible something was wrong with their servers.

rianquinn avatar Mar 20 '19 01:03 rianquinn

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.

ihalip avatar Mar 20 '19 06:03 ihalip

I was unable to sign it yesterday as well, but I can today. Try again now.

matt-dees avatar Mar 21 '19 18:03 matt-dees

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.

rianquinn avatar Mar 21 '19 18:03 rianquinn

This should be fixed. If it isn't, please feel free to open this again

rianquinn avatar Apr 23 '19 02:04 rianquinn