circt icon indicating copy to clipboard operation
circt copied to clipboard

[Github Actions] Fix macOS build by switching to clang

Open zyedidia opened this issue 1 year ago • 1 comments

While trying to use the Mac firtool pre-built binary on a larger design I noticed that it sometimes throws bogus errors, for example saying that a value is not fully initialized when in fact it is, while the Linux prebuilt binary works just fine on the same file. I did some testing and determined that these errors appear in the Mac CIRCT build if using gcc instead of clang. I'm not sure what the cause is -- I looked at the build logs using gcc and noticed there were warnings about weak symbol visibility during linking, but I'm not sure what these warnings really mean.

This PR switches the Mac build to use clang instead of gcc. Firtool now looks like this:

$ otool -L firtool
firtool:
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.0.0)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
	/usr/local/opt/zstd/lib/libzstd.1.dylib (compatibility version 1.0.0, current version 1.5.2)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1200.3.0)

The reason to use gcc over clang was to static link more libraries, but clearly clang must be used on Mac. Let me know if you think we should also use clang for the Linux build, but this PR just changes to clang for Mac.

I'm not sure if we want to support building with gcc on Mac, but it's good to document that it currently doesn't work, and it produces a binary that works on basic examples but not more complex ones. Sorry for not catching this earlier!

zyedidia avatar Aug 12 '22 00:08 zyedidia

I'm actually going to switch the Linux builds over to clang as well because it looks like an upstream commit in LLVM broke the CIRCT build using gcc on Ubuntu 18.04 (not 20.04 though). See here for details: https://github.com/zyedidia/circt/runs/7799272570?check_suite_focus=true.

zyedidia avatar Aug 12 '22 05:08 zyedidia