-mllvm and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together

Hi, I am getting the following error while building my project:

-mllvm and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together

Even though I do not set (manually) the -mllvm option anywhere in my CMakeLists.txt files. The only place where I see the -mllvm option being passed is in the CMakeConfigureLog.yaml log file.

  -
    kind: "try_compile-v1"
    backtrace:
      - "/opt/homebrew/Cellar/cmake/3.30.1/share/cmake/Modules/CMakeDetermineCompilerABI.cmake:74 (try_compile)"
      - "/opt/homebrew/Cellar/cmake/3.30.1/share/cmake/Modules/CMakeTestCXXCompiler.cmake:26 (CMAKE_DETERMINE_COMPILER_ABI)"
      - "CMakeLists.txt:3 (project)"
    checks:
      - "Detecting CXX compiler ABI info"
    directories:
      source: "/Users/wander/Documents/projects/flux/build/macosx-arm64-opengl-debug/CMakeFiles/CMakeScratch/TryCompile-Z4SNgU"
      binary: "/Users/wander/Documents/projects/flux/build/macosx-arm64-opengl-debug/CMakeFiles/CMakeScratch/TryCompile-Z4SNgU"
    cmakeVariables:
      CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS: "CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS-NOTFOUND"
      CMAKE_CXX_FLAGS: ""
      CMAKE_CXX_FLAGS_DEBUG: "-g"
      CMAKE_CXX_SCAN_FOR_MODULES: "OFF"
      CMAKE_EXE_LINKER_FLAGS: ""
      CMAKE_OSX_ARCHITECTURES: "arm64"
      CMAKE_OSX_DEPLOYMENT_TARGET: "11"
      CMAKE_OSX_SYSROOT: "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk"
    buildResult:
      variable: "CMAKE_CXX_ABI_COMPILED"
      cached: true
      stdout: |
        Change Dir: '/Users/wander/Documents/projects/flux/build/macosx-arm64-opengl-debug/CMakeFiles/CMakeScratch/TryCompile-Z4SNgU'
        
        Run Build Command(s): /opt/homebrew/bin/ninja -v cmTC_c3822
        [1/2] /opt/local/bin/clang++-mp-18   -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -mmacosx-version-min=11   -v -Wl,-v -MD -MT CMakeFiles/cmTC_c3822.dir/CMakeCXXCompilerABI.cpp.o -MF CMakeFiles/cmTC_c3822.dir/CMakeCXXCompilerABI.cpp.o.d -o CMakeFiles/cmTC_c3822.dir/CMakeCXXCompilerABI.cpp.o -c /opt/homebrew/Cellar/cmake/3.30.1/share/cmake/Modules/CMakeCXXCompilerABI.cpp
        clang version 18.1.8
        Target: arm64-apple-darwin23.6.0
        Thread model: posix
        InstalledDir: /opt/local/libexec/llvm-18/bin
        clang++: warning: -Wl,-v: 'linker' input unused [-Wunused-command-line-argument]
         (in-process)
         "/opt/local/libexec/llvm-18/bin/clang" -cc1 -triple arm64-apple-macosx11.0.0 -Wundef-prefix=TARGET_OS_ -Werror=undef-prefix -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name CMakeCXXCompilerABI.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -funwind-tables=1 -target-sdk-version=14.5 -fcompatibility-qualified-id-block-type-checking -fvisibility-inlines-hidden-static-local-var -fbuiltin-headers-in-system-modules -fdefine-target-os-macros -target-cpu apple-m1 -target-feature +zcm -target-feature +zcz -target-feature +v8.5a -target-feature +aes -target-feature +crc -target-feature +dotprod -target-feature +complxnum -target-feature +fp-armv8 -target-feature +fullfp16 -target-feature +fp16fml -target-feature +jsconv -target-feature +lse -target-feature +pauth -target-feature +ras -target-feature +rcpc -target-feature +rdm -target-feature +sha2 -target-feature +sha3 -target-feature +neon -target-abi darwinpcs -debugger-tuning=lldb -fdebug-compilation-dir=/Users/wander/Documents/projects/flux/build/macosx-arm64-opengl-debug/CMakeFiles/CMakeScratch/TryCompile-Z4SNgU -target-linker-version 1022.1 -v -fcoverage-compilation-dir=/Users/wander/Documents/projects/flux/build/macosx-arm64-opengl-debug/CMakeFiles/CMakeScratch/TryCompile-Z4SNgU -resource-dir /opt/local/libexec/llvm-18/lib/clang/18 -dependency-file CMakeFiles/cmTC_c3822.dir/CMakeCXXCompilerABI.cpp.o.d -MT CMakeFiles/cmTC_c3822.dir/CMakeCXXCompilerABI.cpp.o -sys-header-deps -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -internal-isystem /opt/local/libexec/llvm-18/bin/../include/c++/v1 -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/local/include -internal-isystem /opt/local/libexec/llvm-18/lib/clang/18/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include -fdeprecated-macro -ferror-limit 19 -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fmax-type-align=16 -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o CMakeFiles/cmTC_c3822.dir/CMakeCXXCompilerABI.cpp.o -x c++ /opt/homebrew/Cellar/cmake/3.30.1/share/cmake/Modules/CMakeCXXCompilerABI.cpp
        clang -cc1 version 18.1.8 based upon LLVM 18.1.8 default target arm64-apple-darwin23.6.0
        ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/local/include"
        ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/Library/Frameworks"
        #include "..." search starts here:
        #include <...> search starts here:
         /opt/local/libexec/llvm-18/bin/../include/c++/v1
         /opt/local/libexec/llvm-18/lib/clang/18/include
         /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include
         /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/System/Library/Frameworks (framework directory)
        End of search list.
        [2/2] : && /opt/local/bin/clang++-mp-18 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -mmacosx-version-min=11 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -v -Wl,-v CMakeFiles/cmTC_c3822.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_c3822   && :
        clang version 18.1.8
        Target: arm64-apple-darwin23.6.0
        Thread model: posix
        InstalledDir: /opt/local/libexec/llvm-18/bin
         "/opt/local/libexec/llvm-18/bin/ld" -demangle -lto_library /opt/local/libexec/llvm-18/lib/libLTO.dylib -dynamic -arch arm64 -platform_version macos 11.0.0 14.5 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -mllvm -enable-linkonceodr-outlining -o cmTC_c3822 -search_paths_first -headerpad_max_install_names -v CMakeFiles/cmTC_c3822.dir/CMakeCXXCompilerABI.cpp.o -lc++ -lSystem /opt/local/libexec/llvm-18/lib/clang/18/lib/darwin/libclang_rt.osx.a
        @(#)PROGRAM:ld PROJECT:ld-1053.12
        BUILD 10:15:51 Mar 29 2024
        configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
        will use ld-classic for: armv6 armv7 armv7s arm64_32 i386 armv6m armv7k armv7m armv7em
        LTO support using: LLVM version 18.1.8 (static support for 29, runtime is 29)
        TAPI support using: Apple TAPI version 15.0.0 (tapi-1500.3.2.2)
        Library search paths:
        	/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/lib
        	/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/lib/swift
        Framework search paths:
        	/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/System/Library/Frameworks
        
      exitCode: 0

Namely in the line (-mllvm -enable-linkonceodr-outlining):

"/opt/local/libexec/llvm-18/bin/ld" -demangle -lto_library /opt/local/libexec/llvm-18/lib/libLTO.dylib -dynamic -arch arm64 -platform_version macos 11.0.0 14.5 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -mllvm -enable-linkonceodr-outlining -o cmTC_c3822 -search_paths_first -headerpad_max_install_names -v CMakeFiles/cmTC_c3822.dir/CMakeCXXCompilerABI.cpp.o -lc++ -lSystem /opt/local/libexec/llvm-18/lib/clang/18/lib/darwin/libclang_rt.osx.a

Is there some way to get rid of using the -mllvm option if I want to pass -fembed-bitcode? Or any other ways to solve this problem?

Full error:

[cmake] -- The CXX compiler identification is Clang 18.1.8
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - failed
[cmake] -- Check for working CXX compiler: /opt/local/bin/clang++-mp-18
[cmake] -- Check for working CXX compiler: /opt/local/bin/clang++-mp-18 - broken
[cmake] CMake Error at /opt/homebrew/Cellar/cmake/3.30.1/share/cmake/Modules/CMakeTestCXXCompiler.cmake:73 (message):
[cmake]   The C++ compiler
[cmake] 
[cmake]     "/opt/local/bin/clang++-mp-18"
[cmake] 
[cmake]   is not able to compile a simple test program.
[cmake] 
[cmake]   It fails with the following output:
[cmake] 
[cmake]     Change Dir: '/Users/wander/Documents/projects/flux/build/macosx-arm64-opengl-debug/external/Catch2/CMakeFiles/CMakeScratch/TryCompile-MiIzTj'
[cmake]     
[cmake]     Run Build Command(s): /opt/homebrew/bin/ninja -v cmTC_b35c8
[cmake]     [1/2] /opt/local/bin/clang++-mp-18   -fembed-bitcode  -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -mmacosx-version-min=11 -MD -MT CMakeFiles/cmTC_b35c8.dir/testCXXCompiler.cxx.o -MF CMakeFiles/cmTC_b35c8.dir/testCXXCompiler.cxx.o.d -o CMakeFiles/cmTC_b35c8.dir/testCXXCompiler.cxx.o -c /Users/wander/Documents/projects/flux/build/macosx-arm64-opengl-debug/external/Catch2/CMakeFiles/CMakeScratch/TryCompile-MiIzTj/testCXXCompiler.cxx
[cmake]     [2/2] : && /opt/local/bin/clang++-mp-18 -fembed-bitcode  -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -mmacosx-version-min=11  CMakeFiles/cmTC_b35c8.dir/testCXXCompiler.cxx.o -o cmTC_b35c8   && :
[cmake]     FAILED: cmTC_b35c8 
[cmake]     : && /opt/local/bin/clang++-mp-18 -fembed-bitcode  -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -mmacosx-version-min=11  CMakeFiles/cmTC_b35c8.dir/testCXXCompiler.cxx.o -o cmTC_b35c8   && :
[cmake]     ld: -mllvm and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together
[cmake]     clang++: error: linker command failed with exit code 1 (use -v to see invocation)
[cmake]     ninja: build stopped: subcommand failed.

Hi, any news or fix about this?

Hi, no news or possible fixes. So, I just disabled this flag in СMake for now.