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

cmake failed on macos #165

Open
EtherDream opened this issue Feb 25, 2024 · 2 comments
Open

cmake failed on macos #165

EtherDream opened this issue Feb 25, 2024 · 2 comments

Comments

@EtherDream
Copy link

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!
@EtherDream EtherDream changed the title cmake error cmake failed on macos Feb 25, 2024
@NicolasCARPi
Copy link

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.

@waterbang
Copy link

waterbang commented Dec 19, 2024

mac m3 arm64

I try to use

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,-export_dynamic" -DCMAKE_CXX_FLAGS="-Ofast -m64 -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,-export_dynamic" -DCMAKE_INSTALL_PREFIX=./installed ..

But it appears when executing the following command:

 ./configure --add-module=/Users/waterbang/Desktop/waterbang/github/ngx_brotli/
checking for OS
 + Darwin 23.6.0 arm64
checking for C compiler ... found
 + using Clang C compiler
checking for -Wl,-E switch ... not found
checking for gcc builtin atomic operations ... not found
checking for C99 variadic macros ... not found
checking for gcc variadic macros ... not found
checking for gcc builtin 64 bit byteswap ... not found
checking for unistd.h ... found
checking for inttypes.h ... found
checking for limits.h ... found
checking for sys/filio.h ... found
checking for sys/param.h ... found
checking for sys/mount.h ... found
checking for sys/statvfs.h ... found
checking for crypt.h ... not found
checking for Darwin specific features
 + kqueue found
checking for kqueue's EVFILT_TIMER ... not found
checking for Darwin 64-bit kqueue millisecond timeout bug ... not found
checking for sendfile() ... not found
checking for atomic(3) ... not found
checking for nobody group ... found
checking for poll() ... not found
checking for /dev/poll ... not found
checking for crypt() ... not found
checking for crypt() in libcrypt ... not found

I think this error can be ignored, because compiling on mac has little meaning and is mainly for the server.

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

3 participants