Clang Xcode 14.0.1 segmentation fault compiling C-code

https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts pulls in yosys which uses abc for optimization. That’s code with a lot of c files.

build_openroad.sh —local

clang 14.0.1 on am M1 randomly coredumps compiling abc .c files.

But not deterministically, restarting ./build_openroad.sh will eventually compile some of them til it finally always coredumps compiling extraUtilMisc.c.

I was able to compile OpenROAD on this machine before I upgraded Xcode.

gmake[2]: Entering directory '/Users/user/OpenROAD-flow-scripts/tools/OpenROAD/build' [ 0%] Building CXX object third-party/abc/CMakeFiles/libabc.dir/src/misc/extra/extraUtilMisc.c.o cd /Users/user/OpenROAD-flow-scripts/tools/OpenROAD/build/third-party/abc && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -I/Users/user/OpenROAD-flow-scripts/tools/OpenROAD/third-party/abc/src -O3 -DNDEBUG -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -Wall -Wno-array-bounds -Wno-nonnull -Wno-unused-variable -Wno-unused-function -Wno-write-strings -Wno-sign-compare -Wno-deprecated -Wno-c++11-narrowing -Wno-register -Wno-format -Wno-reserved-user-defined-literal -DABC_USE_STDINT_H=1 -DABC_MEMALIGN=4 -DABC_NAMESPACE=abc -fpermissive -DABC_USE_CUDD=1 -DABC_USE_PTHREADS -Wno-unused-but-set-variable -std=c++17 -MD -MT third-party/abc/CMakeFiles/libabc.dir/src/misc/extra/extraUtilMisc.c.o -MF CMakeFiles/libabc.dir/src/misc/extra/extraUtilMisc.c.o.d -o CMakeFiles/libabc.dir/src/misc/extra/extraUtilMisc.c.o -c /Users/user/OpenROAD-flow-scripts/tools/OpenROAD/third-party/abc/src/misc/extra/extraUtilMisc.c clang: error: unable to execute command: Segmentation fault: 11 clang: error: clang frontend command failed due to signal (use -v to see invocation) Apple clang version 14.0.0 (clang-1400.0.29.102) Target: arm64-apple-darwin21.6.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

downgrading to command line tools 13.4 Apple clang version 13.1.6 (clang-1316.0.21.2.5) works

I have the same issue with Apple clang version 14.0.0 (clang-1400.0.29.102) Target: arm64-apple-darwin21.6.0

It only happens with optimized code. An alternative workaround for building openroad is to patch the abc cmake file to include -g

third-party/CMakeLists.txt @@ -46,6 +46,10 @@ if (NOT USE_SYSTEM_ABC)

readline is not needed since we call abc from c++

set(READLINE_FOUND FALSE)

+# apple clang 14.0.0 seg faults on abc without -g +add_compile_options(

  • $<$<CXX_COMPILER_ID:AppleClang>:-g>

+) add_subdirectory(abc)

endif()

A Formatted version of  @jjcherry56's answer:

if (NOT USE_SYSTEM_ABC)

  set(ABC_USE_NAMESPACE "abc")

  # abc does not have "platform" support for macos so force it to use stdint.h
  if (CMAKE_OSX_SYSROOT)
     set(ABC_USE_STDINT_H 1)
  endif()

  # make sure not to include readline headers to avoid extra dependencies
  # readline is not needed since we call abc from c++
  set(READLINE_FOUND FALSE)

  # apple clang 14.0.0 seg faults on abc without -g
  add_compile_options($<$<CXX_COMPILER_ID:AppleClang>:-g>)          # <-- ADD

  add_subdirectory(abc)

endif()
Clang Xcode 14.0.1 segmentation fault compiling C-code
 
 
Q