quick-lint / quick-lint-js

quick-lint-js finds bugs in JavaScript programs
https://quick-lint-js.com
GNU General Public License v3.0
1.51k stars 191 forks source link

macOS build instructions don't work on dvmusic's machine #460

Open strager opened 2 years ago

strager commented 2 years ago

macOS 11.6 Xcode 13.0

% PATH="$(brew --prefix)/opt/llvm/bin:$PATH" \
  CC=clang \  
  CXX=clang++ \                                   
  CPPFLAGS="-I$(brew --prefix)/opt/llvm/include" \
  CXXFLAGS=-D_LIBCPP_DISABLE_AVAILABILITY \  
  LDFLAGS="-L$(brew --prefix)/opt/llvm/lib" \          
  cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -S . -B build
-- The C compiler identification is Clang 12.0.1
-- The CXX compiler identification is Clang 12.0.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /usr/local/opt/llvm/bin/clang
-- Check for working C compiler: /usr/local/opt/llvm/bin/clang - broken
CMake Error at /usr/local/Cellar/cmake/3.21.3/share/cmake/Modules/CMakeTestCCompiler.cmake:69 (message):
  The C compiler

    "/usr/local/opt/llvm/bin/clang"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /Users/dav/git/quick-lint-js/build/CMakeFiles/CMakeTmp

    Run Build Command(s):/usr/local/bin/ninja cmTC_8e3c5 && [1/2] Building C object CMakeFiles/cmTC_8e3c5.dir/testCCompiler.c.o
    [2/2] Linking C executable cmTC_8e3c5
    FAILED: cmTC_8e3c5 
    : && /usr/local/opt/llvm/bin/clang -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -L/usr/local/opt/llvm/lib CMakeFiles/cmTC_8e3c5.dir/testCCompiler.c.o -o cmTC_8e3c5   && :
    ld: library not found for -lSystem
    clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
    ninja: build stopped: subcommand failed.

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

-- Configuring incomplete, errors occurred!
See also "/Users/dav/git/quick-lint-js/build/CMakeFiles/CMakeOutput.log".
See also "/Users/dav/git/quick-lint-js/build/CMakeFiles/CMakeError.log".
strager commented 2 years ago

It works after adding -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/lib explicitly to ldflags.

dav000 commented 2 years ago

it worked without modifying LDFLAGS after I installed the current Xcode 13 Command Line Tools package via https://developer.apple.com/download/all/?q=for%20Xcode

adding a note to the build documentation should probably be sufficient.