Menu

#19 macos build failing with pure cmake

5.0
closed
build (8)
2025-02-19
2025-02-09
Brad Lanam
No

Reported by MacPorts: Sonoma w/16.2 compiler fails with pure cmake.

I just tried a pure cmake build under

macOS 14.7.3 23H417 arm64
Xcode 16.2 16C5032a

I still get the same implicit function declaration errors as before.

Tested on seqouia, and the member-xdr tests are failing.
To do:
- Fix pure cmake build on macos, find out why this is failing. both sys/quota.h and rpcsvc/quota.h are being found.
- Add pure cmake testing to all machines with cmake.

Discussion

1 2 3 > >> (Page 1 of 3)
  • Brad Lanam

    Brad Lanam - 2025-02-09

    Damned cmake is doing weird things....

    bll-mac:/Volumes/Users/bll/di$ /Library/Developer/CommandLineTools/usr/bin/cc -I . -o ttt ttt.c
    ttt.c:1:10: fatal error: 'rpcsvc/rquota.h' file not found
        1 | #include <rpcsvc/rquota.h>
          |          ^~~~~~~~~~~~~~~~~
    1 error generated.
    bll-mac:/Volumes/Users/bll/di$
    
    bll-mac:/Volumes/Users/bll/di$ /usr/bin/cc -I . -o ttt ttt.c
    bll-mac:/Volumes/Users/bll/di$
    bll-mac:/Volumes/Users/bll/di$ /usr/bin/clang -I . -o ttt ttt.c
    bll-mac:/Volumes/Users/bll/di$
    
     
  • Brad Lanam

    Brad Lanam - 2025-02-09

    Potential solution. I don't know if XCode includes any other compilers within its suite.
    This could be incorrect if XCode supports compilers other than clang.
    It probably won't hurt anything, as this is only used for the XDR type determination.
    I use the command-line-tools compiler.

    set (MYCC ${CMAKE_C_COMPILER})
    if (APPLE AND ${CMAKE_C_COMPILER} MATCHES "^/Library/Developer/")
      set (MYCC /usr/bin/clang)
    endif()
    
     
  • Brad Lanam

    Brad Lanam - 2025-02-09

    Sequoia (intel):

    bll-g7:bll$ ./tests/testall.sh --fg bll-mac.local
    -- 10:44:14 bll-mac.local: start cc
    -- 10:44:14 bll-mac.local: copying files
    -- 10:44:15 bll-mac.local: pcmake/cc
    -- 10:45:20 bll-mac.local: cmake/cc
    -- 10:46:28 bll-mac.local: mkc/cc
    -- 10:47:04 bll-mac.local: cmake mkc cc tests: 20 failures: 0 
    -- 10:47:04 bll-mac.local: finish
    
     

    Last edit: Brad Lanam 2025-02-09
  • Brad Lanam

    Brad Lanam - 2025-02-09
    • status: accepted --> closed
     
  • Brad Lanam

    Brad Lanam - 2025-02-09

    Big Sur (m1):

    bll-g7:bll$ ./tests/testall.sh --fg bll-mac-m1.local
    -- 10:52:41 bll-mac-m1.local: start cc
    -- 10:52:41 bll-mac-m1.local: copying files
    -- 10:52:43 bll-mac-m1.local: pcmake/cc
    -- 10:53:01 bll-mac-m1.local: cmake/cc
    -- 10:53:22 bll-mac-m1.local: mkc/cc
    -- 10:54:12 bll-mac-m1.local: cmake mkc cc tests: 20 failures: 0 
    -- 10:54:12 bll-mac-m1.local: finish
    

    Sonoma (intel):

    bll-g7:bll$ ./tests/testall.sh --fg bll-mac.local
    -- 10:56:26 bll-mac.local: start cc
    -- 10:56:26 bll-mac.local: copying files
    -- 10:56:28 bll-mac.local: pcmake/cc
    -- 10:57:11 bll-mac.local: cmake/cc
    -- 10:57:55 bll-mac.local: mkc/cc
    -- 10:58:23 bll-mac.local: cmake mkc cc tests: 20 failures: 0 
    -- 10:58:23 bll-mac.local: finish
    

    Fixed in 5.0.6.

     
  • Brad Lanam

    Brad Lanam - 2025-02-09

    And Sequoia (m1):

    bll-g7:bll$ ./tests/testall.sh --fg bll-mac-m1.local
    -- 11:32:14 bll-mac-m1.local: start cc
    -- 11:32:14 bll-mac-m1.local: copying files
    -- 11:32:16 bll-mac-m1.local: pcmake/cc
    -- 11:32:38 bll-mac-m1.local: cmake/cc
    -- 11:33:02 bll-mac-m1.local: mkc/cc
    -- 11:33:20 bll-mac-m1.local: cmake mkc cc tests: 20 failures: 0 
    -- 11:33:20 bll-mac-m1.local: finish
    
     
  • Brad Lanam

    Brad Lanam - 2025-02-10

    Fixed in 5.0.6

     
  • Marius Schamschula

    I still see the same comple error when using pure cmake for version 5.0.6:

    config.h has the following lines

    #define _mem_struct_rquota_rq_bhardlimit 1
    #define _mem_struct_getquota_args_gqa_uid 1
    #define xdr_rq_bhardlimit xdr_
    #define xdr_rq_bsoftlimit xdr_
    #define xdr_rq_curblocks xdr_
    #define xdr_rq_fhardlimit xdr_
    #define xdr_rq_fsoftlimit xdr_
    #define xdr_rq_curfiles xdr_
    #define xdr_gqa_uid xdr_
    

    and then the compile fails with

    make[2]: Leaving directory `/opt/local/var/macports/build/_Users_marius_Development_MacPorts_ports_sysutils_di/di/work/build'
    [ 75%] Built target dimathtest
    /opt/local/var/macports/build/_Users_marius_Development_MacPorts_ports_sysutils_di/di/work/di-5.0.6/diquota.c:534:9: error: call to undeclared function 'xdr_'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
      534 |   if (! xdr_gqa_uid (xp, &args->gqa_uid)) {
          |         ^
    /opt/local/var/macports/build/_Users_marius_Development_MacPorts_ports_sysutils_di/di/work/build/config.h:156:21: note: expanded from macro 'xdr_gqa_uid'
      156 | #define xdr_gqa_uid xdr_
          |                     ^
    /opt/local/var/macports/build/_Users_marius_Development_MacPorts_ports_sysutils_di/di/work/di-5.0.6/diquota.c:569:9: error: call to undeclared function 'xdr_'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
      569 |   if (! xdr_rq_bhardlimit (xp, &rptr->rq_bhardlimit)) {
          |         ^
    /opt/local/var/macports/build/_Users_marius_Development_MacPorts_ports_sysutils_di/di/work/build/config.h:150:27: note: expanded from macro 'xdr_rq_bhardlimit'
      150 | #define xdr_rq_bhardlimit xdr_
          |                           ^
    2 errors generated.
    

    I have no idea where xdr_ would come from.

     
  • Brad Lanam

    Brad Lanam - 2025-02-10
    • status: closed --> accepted
     
  • Brad Lanam

    Brad Lanam - 2025-02-10

    Was this on Sonoma again?

     
  • Brad Lanam

    Brad Lanam - 2025-02-10

    Sonoma:

    bll-mac:/Volumes/Users/bll/di$ cmake -S . -DCMAKE_INSTALL_PREFIX=$(pwd)/x -B build
    ...
    bll-mac:/Volumes/Users/bll/di$ echo $?
    0
    bll-mac:/Volumes/Users/bll/di$ cmake --build build
    [  6%] Building C object CMakeFiles/objdistrutils.dir/distrutils.c.o
    [  6%] Built target objdistrutils
    [ 12%] Building C object CMakeFiles/libdi.dir/didiskutil.c.o
    [ 18%] Building C object CMakeFiles/libdi.dir/digetentries.c.o
    [ 25%] Building C object CMakeFiles/libdi.dir/digetinfo.c.o
    [ 31%] Building C object CMakeFiles/libdi.dir/dilib.c.o
    [ 37%] Building C object CMakeFiles/libdi.dir/diquota.c.o
    [ 43%] Building C object CMakeFiles/libdi.dir/dizone.c.o
    [ 50%] Building C object CMakeFiles/libdi.dir/getoptn.c.o
    [ 56%] Building C object CMakeFiles/libdi.dir/dioptions.c.o
    [ 62%] Linking C shared library libdi.dylib
    [ 62%] Built target libdi
    [ 68%] Building C object CMakeFiles/di.dir/di.c.o
    [ 75%] Linking C executable di
    [ 75%] Built target di
    [ 81%] Building C object CMakeFiles/dimathtest.dir/dimathtest.c.o
    [ 87%] Linking C executable dimathtest
    [ 87%] Built target dimathtest
    [ 93%] Building C object CMakeFiles/getoptn_test.dir/getoptn.c.o
    [100%] Linking C executable getoptn_test
    [100%] Built target getoptn_test
    bll-mac:/Volumes/Users/bll/di$ cmake --install build
    -- Install configuration: ""
    -- Installing: /Volumes/Users/bll/di/x/lib/libdi.5.0.6.dylib
    -- Installing: /Volumes/Users/bll/di/x/lib/libdi.5.dylib
    -- Installing: /Volumes/Users/bll/di/x/lib/libdi.dylib
    -- Installing: /Volumes/Users/bll/di/x/bin/di
    -- Installing: /Volumes/Users/bll/di/x/include/di.h
    -- Installing: /Volumes/Users/bll/di/x/share/man/man1/di.1
    -- Installing: /Volumes/Users/bll/di/x/share/man/man3/libdi.3
    -- Installing: /Volumes/Users/bll/di/x/lib/pkgconfig/di.pc
    instpo.sh: Unable to locate msgfmt command
    bll-mac:/Volumes/Users/bll/di$ ./x/bin/di  .
    Filesystem   Mount           Size  Used Avail %Used
    /dev/disk1s1 /Volumes/Users 36.8G 14.1G 22.7G   38%
    
     
  • Brad Lanam

    Brad Lanam - 2025-02-11

    I think my path check for MacOS fails for XCode.
    I need to know what cmake's CMAKE_C_COMPILER is set to when using XCode.

     
  • Brad Lanam

    Brad Lanam - 2025-02-11

    I don't have enough disk space available to install xcode.

     
  • Brad Lanam

    Brad Lanam - 2025-02-11

    Can you try beta/di-5.0.7.tar.gz?

     
  • Marius Schamschula

    5.0.7 beta still does the same thing.

     
  • Marius Schamschula

    In config.h I pure cmake generates

    define xdr_rq_bhardlimit xdr_

    define xdr_rq_bsoftlimit xdr_

    define xdr_rq_curblocks xdr_

    define xdr_rq_fhardlimit xdr_

    define xdr_rq_fsoftlimit xdr_

    define xdr_rq_curfiles xdr_

    define xdr_gqa_uid xdr_

    white having autotools call cmake gnerates

    define xdr_rq_bhardlimit xdr_u_int

    define xdr_rq_bsoftlimit xdr_u_int

    define xdr_rq_curblocks xdr_u_int

    define xdr_rq_fhardlimit xdr_u_int

    define xdr_rq_fsoftlimit xdr_u_int

    define xdr_rq_curfiles xdr_u_int

    define xdr_gqa_uid xdr_int

    The only other difference I see is that autotools creates the build folder within the di-5.0.x, while MacPorts cmake creates the build folder at the same level as di-5.0.x.

     
  • Brad Lanam

    Brad Lanam - 2025-02-15

    Thanks for taking the time to test with 5.0.7.

    The problem is that cmake is setting the compiler path to /Library/Developer/CommandLineTools/usr/bin/cc (for command line tools), which is not a user-friendly compiler -- it will not compile a source file without additional arguments. I need a path such as /usr/bin/clang.

    I have to run the compiler on a small test file ( ${MYCC} -I ${tinc} -E ${membernm}.c) in order to get and extract the xdr types.

    I put in a test in 5.0.7 to check for /Applications/Xcode.app/, but I was mostly guessing at what path Xcode would use.

    Can you add a line to CMakeLists.txt:
    message (FATAL_ERROR "== compiler: ${CMAKE_C_COMPILER}")
    around line 78 or so.
    Or I can make a new beta version with some debugging in it.

    Sorry, I can't install Xcode as I have no disk space for it, and I don't have access to MacOS with Xcode.

     
  • Marius Schamschula

    Sure enough:

    :info:configure CMake Error at CMakeLists.txt:85 (message):
    :info:configure   == compiler: /usr/bin/clang
    :info:configure -- Configuring incomplete, errors occurred!
    
     
  • Brad Lanam

    Brad Lanam - 2025-02-15

    This is really weird. /usr/bin/clang should work fine.
    I have an assumption that /usr/bin/clang will work if Xcode is installed. It does when command line tools is installed.

    The test file that gets compiled (actually just pre-processed) is:

    #include <rpcsvc/rquota.h>
    int main (int argc, char *argv []) { return 0; }
    
    bll-mac:/Volumes/Users/bll/di$ /Library/Developer/CommandLineTools/usr/bin/cc -o tt tt.c
    tt.c:1:10: fatal error: 'rpcsvc/rquota.h' file not found
        1 | #include <rpcsvc/rquota.h>
          |          ^~~~~~~~~~~~~~~~~
    1 error generated.
    bll-mac:/Volumes/Users/bll/di$ /usr/bin/clang -o tt tt.c
    bll-mac:/Volumes/Users/bll/di$ 
    

    As you can see, the CMAKE_C_COMPILER that gets set with command line tools doesn't have the include path built in.

    Essentially I just need any working C compiler. I will do some research on cmake and see if I can figure out how to run theirs. If you have any ideas, I am completely open.

     
  • Marius Schamschula

    Here is a bit more info about what Xcode/CLT install

    marius@Mira ports % /usr/bin/clang --version
    Apple clang version 16.0.0 (clang-1600.0.26.6)
    Target: arm64-apple-darwin23.6.0
    Thread model: posix
    InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
    marius@Mira ports % /Library/Developer/CommandLineTools/usr/bin/clang --version
    Apple clang version 16.0.0 (clang-1600.0.26.6)
    Target: arm64-apple-darwin23.6.0
    Thread model: posix
    InstalledDir: /Library/Developer/CommandLineTools/usr/bin
    marius@Mira ports % /Library/Developer/CommandLineTools/usr/bin/clang --version
    Apple clang version 16.0.0 (clang-1600.0.26.6)
    Target: arm64-apple-darwin23.6.0
    Thread model: posix
    InstalledDir: /Library/Developer/CommandLineTools/usr/bin
    

    However, they are not the same

    marius@Mira ports % ls -l /Library/Developer/CommandLineTools/usr/bin/clang
    -rwxr-xr-x  1 root  wheel  257149376 Dec  7 01:15 /Library/Developer/CommandLineTools/usr/bin/clang
    marius@Mira ports % ls -l /usr/bin/clang                                   
    -rwxr-xr-x  77 root  wheel  119008 Jan 15 08:21 /usr/bin/clang
    
     

    Last edit: Marius Schamschula 2025-02-15
  • Brad Lanam

    Brad Lanam - 2025-02-15
    export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
    bll-mac:/Volumes/Users/bll/di$ /Library/Developer/CommandLineTools/usr/bin/cc -o tt tt.c
    bll-mac:/Volumes/Users/bll/di$ 
    

    Well, this works. I guess I can try to put this in the CMakeLists.txt file.

     
  • Marius Schamschula

    I think we're trying to set things that the cmake PortGroup has already set for us.

    Here's what the configure command invokes:

    --->  Configuring di
            (using ccache)
    Executing:  cd "/opt/local/var/macports/build/_Users_marius_Development_MacPorts_ports_sysutils_di/di/work/build" && /opt/local/bin/cmake -G "CodeBlocks - Unix Makefiles" -DCMAKE_BUILD_TYPE=MacPorts -DCMAKE_INSTALL_PREFIX="/opt/local" -DCMAKE_INSTALL_NAME_DIR="/opt/local/lib" -DCMAKE_SYSTEM_PREFIX_PATH="/opt/local;/usr" -DCMAKE_C_COMPILER_LAUNCHER=/opt/local/bin/ccache -DCMAKE_CXX_COMPILER_LAUNCHER=/opt/local/bin/ccache -DCMAKE_Fortran_COMPILER_LAUNCHER=/opt/local/bin/ccache -DCMAKE_OBJC_COMPILER_LAUNCHER=/opt/local/bin/ccache -DCMAKE_OBJCXX_COMPILER_LAUNCHER=/opt/local/bin/ccache -DCMAKE_ISPC_COMPILER_LAUNCHER=/opt/local/bin/ccache -DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX" -DCMAKE_OBJC_COMPILER="$CC" -DCMAKE_OBJCXX_COMPILER="$CXX" -DCMAKE_POLICY_DEFAULT_CMP0025=NEW -DCMAKE_POLICY_DEFAULT_CMP0060=NEW -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_COLOR_MAKEFILE=ON -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_MAKE_PROGRAM=/usr/bin/make -DCMAKE_MODULE_PATH="/opt/local/share/cmake/Modules" -DCMAKE_PREFIX_PATH="/opt/local/share/cmake/Modules" -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON -DCMAKE_INSTALL_RPATH="/opt/local/lib" -Wno-dev -DDI_MATH=DI_INTERNAL -DCMAKE_OSX_ARCHITECTURES="arm64" -DCMAKE_OSX_DEPLOYMENT_TARGET="14.0" -DCMAKE_OSX_SYSROOT="/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk" /opt/local/var/macports/build/_Users_marius_Development_MacPorts_ports_sysutils_di/di/work/di-5.0.7 
    

    Of course some items are ignored:

    CMake Warning:
      Manually-specified variables were not used by the project:
    
        CMAKE_CXX_COMPILER
        CMAKE_OBJCXX_COMPILER
        CMAKE_OBJC_COMPILER
        CMAKE_POLICY_DEFAULT_CMP0025
        CMAKE_POLICY_DEFAULT_CMP0060
        DI_MATH
    

    The last one was deliberately set to deal with https://trac.macports.org/ticket/71791

     
  • Brad Lanam

    Brad Lanam - 2025-02-15

    Ok, can you try beta/di-5.0.8.tar.gz ?
    I set SDKROOT if it is not already set. This works with CLT.

     
  • Brad Lanam

    Brad Lanam - 2025-02-15

    The cmake documentation says that CMAKE_SYSTEM_PREFIX_PATH is not supposed to be for users to mess with, but whatever works.

    Setting DI_MATH is fine, nothing wrong with that. pkg-config is deliberately excluded, so it won't find libtommath, but I would leave DI_MATH there until such time someone wants to create a GMP variant. The non-GMP variant would need to set DI_MATH=DI_INTERNAL, otherwise the bad libtommath might be picked up.

     
  • Brad Lanam

    Brad Lanam - 2025-02-15

    Whoops. 5.0.8 is an abject failure.

     
1 2 3 > >> (Page 1 of 3)

Log in to post a comment.

MongoDB Logo MongoDB