From f8cd27a7f8ad389cc7a6dd9a1f1dc82efc2efc8b Mon Sep 17 00:00:00 2001 From: Sungkeun Cho Date: Thu, 5 Oct 2023 05:15:56 -0700 Subject: [PATCH] [clang] Revise cmake options Summary: This diff revises the cmake options of the clang for working better with the latest versions. Reviewed By: jvillard Differential Revision: D49949227 fbshipit-source-id: 0caaf3fdcf66eefcc6341740e54661179e3ce55e --- facebook-clang-plugins/Makefile.common | 5 ++--- facebook-clang-plugins/clang/setup.sh | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/facebook-clang-plugins/Makefile.common b/facebook-clang-plugins/Makefile.common index 66e90d55733..99def7ca6fc 100644 --- a/facebook-clang-plugins/Makefile.common +++ b/facebook-clang-plugins/Makefile.common @@ -12,9 +12,8 @@ IOSFLAGS=-isysroot $(SDKPATH) -mios-simulator-version-min=8.2 -target x86_64-app -Wno-objc-property-implementation endif -# we assume that the targeted clang was configured with --enable-libcpp --enable-cxx17 -CFLAGS_Darwin+=-stdlib=libc++ -std=c++17 -LDFLAGS_Darwin+=-stdlib=libc++ +CFLAGS_Darwin+=-std=c++17 +LDFLAGS_Darwin+= CFLAGS_Linux+=-std=c++17 -fPIC LDFLAGS_Linux+= diff --git a/facebook-clang-plugins/clang/setup.sh b/facebook-clang-plugins/clang/setup.sh index 1fedd3cc863..f952bed6e09 100755 --- a/facebook-clang-plugins/clang/setup.sh +++ b/facebook-clang-plugins/clang/setup.sh @@ -166,12 +166,12 @@ CMAKE_ARGS=( -DCMAKE_C_FLAGS="$CFLAGS $CMAKE_C_FLAGS" -DCMAKE_CXX_FLAGS="$CXXFLAGS $CPPFLAGS $CMAKE_CXX_FLAGS" -DCMAKE_INSTALL_PREFIX="$CLANG_PREFIX" - -DLLVM_BUILD_EXTERNAL_COMPILER_RT=On -DLLVM_BUILD_TOOLS=Off -DLLVM_ENABLE_ASSERTIONS=Off -DLLVM_ENABLE_EH=On -DLLVM_ENABLE_RTTI=On - -DLLVM_INCLUDE_DOCS=Off + -DLLVM_BUILD_DOCS=Off + -DLLVM_INCLUDE_BENCHMARKS=Off -DLLVM_INCLUDE_EXAMPLES=Off -DLLVM_INCLUDE_TESTS=Off -DLLVM_TARGETS_TO_BUILD="X86;AArch64;ARM;Mips" @@ -179,7 +179,6 @@ CMAKE_ARGS=( if [ "$PLATFORM" = "Darwin" ]; then CMAKE_ARGS+=( - -DLLVM_ENABLE_LIBCXX=On -DCMAKE_SHARED_LINKER_FLAGS="$LDFLAGS $CMAKE_SHARED_LINKER_FLAGS" -DLLVM_BUILD_LLVM_DYLIB=ON ) @@ -191,19 +190,22 @@ fi if [[ "$PLATFORM" = "Linux" ]] && [[ -n "${PLATFORM_ENV}" ]] ; then # Please note that this case only applies to infer/master platform builds - # Prevent CMAKE from adding -isystem /usr/include for platform builds CMAKE_ARGS+=( - -DLLVM_ENABLE_PROJECTS="clang;compiler-rt" - -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" + -DLLVM_ENABLE_PROJECTS="clang" + -DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxx;libcxxabi" -DZLIB_INCLUDE_DIR="$ZLIB/include" + # We disable some tools to avoid adding -isystem /usr/include in platform builds. It is good + # enough for now, but if we want to use them, we should give proper include directories as + # we did for zlib above. -DLLVM_ENABLE_LIBXML2=Off -DLLVM_ENABLE_TERMINFO=Off -DLLVM_ENABLE_Z3_SOLVER=Off -DLLVM_ENABLE_ZSTD=Off ) else - CMAKE_ARGS+=(-DLLVM_ENABLE_PROJECTS="clang;compiler-rt;openmp" - -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" + CMAKE_ARGS+=( + -DLLVM_ENABLE_PROJECTS="clang" + -DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxx;libcxxabi;openmp" ) fi