Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: juceaide can't be linked with homebrew llvm #241

Closed
1 task done
wang-edward opened this issue Jan 3, 2025 · 6 comments
Closed
1 task done

[Bug]: juceaide can't be linked with homebrew llvm #241

wang-edward opened this issue Jan 3, 2025 · 6 comments

Comments

@wang-edward
Copy link

wang-edward commented Jan 3, 2025

Detailed steps on how to reproduce the bug

when llvm is installed through homebrew, and cmake uses the /opt/homebrew/opt/llvm/bin/clang compiler, juceaide fails to link.

-- The C compiler identification is Clang 19.1.6
-- The CXX compiler identification is Clang 19.1.6
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/homebrew/opt/llvm/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/homebrew/opt/llvm/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring juceaide
-- Building juceaide
CMake Error at external/tracktion_engine/modules/juce/extras/Build/juceaide/CMakeLists.txt:142 (message):
  Failed to build juceaide

  [ 9%] Building CXX object
  extras/Build/juceaide/CMakeFiles/juceaide.dir/Main.cpp.o

  [ 18%] Building CXX object
  extras/Build/juceaide/CMakeFiles/juceaide.dir/__/juce_build_tools/juce_build_tools.cpp.o


  [ 27%] Building CXX object
  extras/Build/juceaide/CMakeFiles/juceaide.dir/__/__/__/modules/juce_gui_basics/juce_gui_basics.mm.o


  In file included from
  /Users/edw/github/box/external/tracktion_engine/modules/juce/modules/juce_gui_basics/juce_gui_basics.mm:35:


  In file included from
  /Users/edw/github/box/external/tracktion_engine/modules/juce/modules/juce_gui_basics/juce_gui_basics.cpp:187:



  /Users/edw/github/box/external/tracktion_engine/modules/juce/modules/juce_gui_basics/native/juce_NSViewComponentPeer_mac.mm:1636:23:
  warning: variable 'target' set but not used [-Wunused-but-set-variable]

   1636 |             if (auto* target = findCurrentTextInputTarget())
        |                       ^

  1 warning generated.

  [ 36%] Building CXX object
  extras/Build/juceaide/CMakeFiles/juceaide.dir/__/__/__/modules/juce_graphics/juce_graphics_Harfbuzz.cpp.o


  [ 45%] Building C object
  extras/Build/juceaide/CMakeFiles/juceaide.dir/__/__/__/modules/juce_graphics/juce_graphics_Sheenbidi.c.o


  [ 54%] Building CXX object
  extras/Build/juceaide/CMakeFiles/juceaide.dir/__/__/__/modules/juce_graphics/juce_graphics.mm.o


  [ 63%] Building CXX object
  extras/Build/juceaide/CMakeFiles/juceaide.dir/__/__/__/modules/juce_events/juce_events.mm.o


  [ 72%] Building CXX object
  extras/Build/juceaide/CMakeFiles/juceaide.dir/__/__/__/modules/juce_core/juce_core_CompilationTime.cpp.o


  [ 81%] Building CXX object
  extras/Build/juceaide/CMakeFiles/juceaide.dir/__/__/__/modules/juce_core/juce_core.mm.o


  [ 90%] Building CXX object
  extras/Build/juceaide/CMakeFiles/juceaide.dir/__/__/__/modules/juce_data_structures/juce_data_structures.mm.o


  [100%] Linking CXX executable juceaide_artefacts/Debug/juceaide

  Undefined symbols for architecture arm64:

    "std::exception_ptr::__from_native_exception_pointer(void*)", referenced from:
        std::exception_ptr std::make_exception_ptr[abi:ne190106]<std::__1::future_error>(std::__1::future_error) in juce_core.mm.o
    "___cxa_init_primary_exception", referenced from:
        std::exception_ptr std::make_exception_ptr[abi:ne190106]<std::__1::future_error>(std::__1::future_error) in juce_core.mm.o

  ld: symbol(s) not found for architecture arm64

  clang++: error: linker command failed with exit code 1 (use -v to see
  invocation)

  gmake[2]: ***
  [extras/Build/juceaide/CMakeFiles/juceaide.dir/build.make:244:
  extras/Build/juceaide/juceaide_artefacts/Debug/juceaide] Error 1

  gmake[1]: *** [CMakeFiles/Makefile2:148:
  extras/Build/juceaide/CMakeFiles/juceaide.dir/all] Error 2

  gmake: *** [Makefile:136: all] Error 2

What is the expected behaviour?

That it links properly

Operating systems

macOS

What versions of the operating systems?

MacOS Ventura 13.3.1

Architectures

ARM (M1 Macbook Air)

Stacktrace

No response

Plug-in formats (if applicable)

No response

Plug-in host applications (DAWs) (if applicable)

No response

Testing on the develop branch

The bug is present on the develop branch

Code of Conduct

  • I agree to follow the Code of Conduct
@wang-edward wang-edward changed the title [Bug]: juceaide can't be linked with homebrew [Bug]: juceaide can't be linked with homebrew llvm Jan 3, 2025
@drowaudio
Copy link
Contributor

What command are you running to get to that point?

I think you might need to report this to the juce team... Does juce build from the modules/juce submodule?

If not, does it build from the juce tip?

@wang-edward
Copy link
Author

My process for compiling tracktion_engine is:

$ brew install llvm
$ cmake -DCMAKE_BUILD_TYPE=Debug -B build

I tried building juce:master and it compiled fine:

edw@goat ~/github/JUCE (master) $ which clang
/opt/homebrew/opt/llvm/bin/clang
edw@goat ~/github/JUCE (master) $ cmake . -B cmake-build -DJUCE_BUILD_EXAMPLES=ON -DJUCE_BUILD_EXTRAS=ON -DCMAKE_BUILD_TYPE=Debug
-- Configuring juceaide
-- Building juceaide
-- Exporting juceaide
-- Testing juceaide
-- Finished setting up juceaide
-- Configuring done (51.7s)
-- Generating done (1.0s)
-- Build files have been written to: /Users/edw/github/JUCE/cmake-build

@drowaudio
Copy link
Contributor

drowaudio commented Jan 7, 2025

Hmm, I can't even get that far:

dave@MacBook-Pro tracktion_engine % cmake -DCMAKE_BUILD_TYPE=Debug -B build          
-- The C compiler identification is Clang 19.1.6
-- The CXX compiler identification is Clang 19.1.6
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /opt/homebrew/opt/llvm/bin/clang
-- Check for working C compiler: /opt/homebrew/opt/llvm/bin/clang - broken
CMake Error at /opt/homebrew/Cellar/cmake/3.25.2/share/cmake/Modules/CMakeTestCCompiler.cmake:70 (message):
  The C compiler

    "/opt/homebrew/opt/llvm/bin/clang"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /Users/dave/Documents/Developement/Code/Tracktion/waveform/modules/tracktion_engine/build/CMakeFiles/CMakeScratch/TryCompile-2k9aCi
    
    Run Build Command(s):/usr/bin/make -f Makefile cmTC_8a0df/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make  -f CMakeFiles/cmTC_8a0df.dir/build.make CMakeFiles/cmTC_8a0df.dir/build
    Building C object CMakeFiles/cmTC_8a0df.dir/testCCompiler.c.o
    /opt/homebrew/opt/llvm/bin/clang   -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk -mmacosx-version-min=15.1 -MD -MT CMakeFiles/cmTC_8a0df.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_8a0df.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_8a0df.dir/testCCompiler.c.o -c /Users/dave/Documents/Developement/Code/Tracktion/waveform/modules/tracktion_engine/build/CMakeFiles/CMakeScratch/TryCompile-2k9aCi/testCCompiler.c
    Linking C executable cmTC_8a0df
    /opt/homebrew/Cellar/cmake/3.25.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_8a0df.dir/link.txt --verbose=1
    /opt/homebrew/opt/llvm/bin/clang  -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk -mmacosx-version-min=15.1 -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_8a0df.dir/testCCompiler.c.o -o cmTC_8a0df 
    ld: library 'System' not found
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make[1]: *** [cmTC_8a0df] Error 1
    make: *** [cmTC_8a0df/fast] Error 2
    
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:6 (project)


-- Configuring incomplete, errors occurred!

Can I ask how you're specifying cmake to use llvm?
For the above I used

export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"
export CC=/opt/homebrew/opt/llvm/bin/clang
export CXX=/opt/homebrew/opt/llvm/bin/clang++

@wang-edward
Copy link
Author

Sorry for the late response.
I'm doing:

export PATH="/opt/homebrew/opt/llvm/bin:$PATH"
export CC=clang
export CXX=clang++

@drowaudio
Copy link
Contributor

I'm sorry but I can't get this to work either.

I can't even build juce as it can't seem to find the MacOS SDK libraries and frameworks, even though the -isysroot looks correct. If you get any further let me know but at the moment only AppleClang is officially supported on macOS I'm afraid.

@wang-edward
Copy link
Author

It's all good. I was actually using homebrew llvm by accident, and was confused why it wasn't working.
AppleClang is perfectly capable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants