google / ngx_brotli

NGINX module for Brotli compression
BSD 2-Clause "Simplified" License
2.09k stars 215 forks source link

cmake failed on macos #165

Open EtherDream opened 8 months ago

EtherDream commented 8 months ago

run:

cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS="-Ofast -m64 -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections" -DCMAKE_CXX_FLAGS="-Ofast -m64 -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections" -DCMAKE_INSTALL_PREFIX=./installed ..

error:

-- The C compiler identification is AppleClang 15.0.0.15000100
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - broken
CMake Error at /opt/homebrew/Cellar/cmake/3.26.4/share/cmake/Modules/CMakeTestCCompiler.cmake:67 (message):
  The C compiler

    "/Library/Developer/CommandLineTools/usr/bin/cc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /tmp/ngx-setup/ngx_brotli/deps/brotli/out/CMakeFiles/CMakeScratch/TryCompile-vH80hW

    Run Build Command(s):/opt/homebrew/Cellar/cmake/3.26.4/bin/cmake -E env VERBOSE=1 /usr/bin/make -f Makefile cmTC_9bf7f/fast && /Library/Developer/CommandLineTools/usr/bin/make  -f CMakeFiles/cmTC_9bf7f.dir/build.make CMakeFiles/cmTC_9bf7f.dir/build
    Building C object CMakeFiles/cmTC_9bf7f.dir/testCCompiler.c.o
    /Library/Developer/CommandLineTools/usr/bin/cc   -Ofast -m64 -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections  -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk -MD -MT CMakeFiles/cmTC_9bf7f.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_9bf7f.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_9bf7f.dir/testCCompiler.c.o -c /tmp/ngx-setup/ngx_brotli/deps/brotli/out/CMakeFiles/CMakeScratch/TryCompile-vH80hW/testCCompiler.c
    clang: warning: -Wl,--gc-sections: 'linker' input unused [-Wunused-command-line-argument]
    Linking C executable cmTC_9bf7f
    /opt/homebrew/Cellar/cmake/3.26.4/bin/cmake -E cmake_link_script CMakeFiles/cmTC_9bf7f.dir/link.txt --verbose=1
    /Library/Developer/CommandLineTools/usr/bin/cc -Ofast -m64 -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections  -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_9bf7f.dir/testCCompiler.c.o -o cmTC_9bf7f 
    ld: unknown options: --gc-sections 
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make[1]: *** [cmTC_9bf7f] Error 1
    make: *** [cmTC_9bf7f/fast] Error 2

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

-- Configuring incomplete, errors occurred!
NicolasCARPi commented 8 months ago

The error appears at the configure stage. Maybe try and update your build tooling. cmake latest version is 3.29, you're using 3.26. But this is not a brotli issue. Also, I'm not even sure this project can be easily compiled on Mac OS (maybe, maybe not).

Because at the end of the day, it's very likely nginx will run on GNU/Linux, so maybe another approach for you would be to use Docker instead of your native tooling, which, to be honest, is not great on Mac.

Mac OS is a great operating system that allows you to open Safari and browse Apple.com to buy a newer mac. But IMHO it's not so great when you want to do things such as compiling a webserver encoding module in C.