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

macOS build failure #4

Closed
adah1972 opened this issue Aug 6, 2024 · 8 comments
Closed

macOS build failure #4

adah1972 opened this issue Aug 6, 2024 · 8 comments
Assignees

Comments

@adah1972
Copy link

adah1972 commented Aug 6, 2024

Describe the bug
The described steps do not work on macOS.

Desktop (please complete the following information):

  • OS: macOS
  • Version 13.6.8

Additional context
As hinted in README, I followed the Linux steps.

$ mkdir build_mac && cd build_mac
$ cmake -B clangconf -DCMAKE_BUILD_TYPE=Release ../cmake/clangconf
…
$ cmake --build clangconf -- clang runtimes -j8
…
$ cmake -DCMAKE_C_COMPILER=$PWD/llvm/bin/clang -DCMAKE_CXX_COMPILER=$PWD/llvm/bin/clang -DCMAKE_BUILD_TYPE=Release ..
…
$ cmake --build . -- protoc -j8
…
[100%] Built target llvm-libtool-darwin
[100%] Linking CXX executable ../../bin/llvm-objdump
[100%] Built target llvm-objdump
[100%] Clobbering bootstrap build and stamp directories
[100%] Built target runtimes-clobber
[100%] No download step for 'runtimes'
[100%] No update step for 'runtimes'
[100%] No patch step for 'runtimes'
[100%] Performing configure step for 'runtimes'
Not searching for unused variables given on the command line.
CMake Error: The current CMakeCache.txt directory /Users/adah/Programming/icpp/build/llvm/runtimes/runtimes-bins/CMakeCache.txt is different than the directory /home/adah/Programming/icpp/build/llvm/runtimes/runtimes-bins where CMakeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure, reedit the CMakeCache.txt
CMake Error: The source "/Users/adah/Programming/icpp/third/llvm-project/runtimes/CMakeLists.txt" does not match the source "/home/adah/Programming/icpp/third/llvm-project/runtimes/CMakeLists.txt" used to generate cache.  Re-run cmake with a different source directory.
make[3]: *** [/Users/adah/Programming/icpp/build/llvm/runtimes/runtimes-stamps/runtimes-configure] Error 1
make[2]: *** [/Users/adah/Programming/icpp/build/llvm/runtimes/CMakeFiles/runtimes.dir/all] Error 2
make[1]: *** [/Users/adah/Programming/icpp/build/llvm/runtimes/CMakeFiles/runtimes.dir/rule] Error 2
make: *** [runtimes] Error 2

I went a bit farther with Apple Clang, but it failed on std::format during the cmake --build . -- icpp icppcli imod iopad icpp-gadget icpp-server -j8 step.

@GeekNeo
Copy link
Contributor

GeekNeo commented Aug 6, 2024

The log you post is very confusing. Generally, when you execute: "cmake --build . -- protoc -j8", there's no way to get into the runtimes libcxx's building unless some cmake directory is in the wrong place.

@adah1972
Copy link
Author

adah1972 commented Aug 6, 2024

The log you post is very confusing. Generally, when you execute: "cmake --build . -- protoc -j8", there's no way to get into the runtimes libcxx's building unless some cmake directory is in the wrong place.

"It works on my box"?

That was my truthful experience. I suggest you may test on a brand-new Mac to see whether you can reproduce the issues.

@adah1972
Copy link
Author

adah1972 commented Aug 6, 2024

Following the standard non-Linux macOS build procedure, I got past the protoc step:

$ mkdir build_mac2 && cd build_mac2
$ cmake -DCMAKE_BUILD_TYPE=Release ..
…
$ cmake --build . -- protoc -j8
…
$ cmake --build . -- icpp icppcli imod iopad icpp-gadget icpp-server -j8
…
[ 98%] Building CXX object src/CMakeFiles/icpp.dir/runcfg.cpp.o
/Users/yongwei/Programming/icpp/src/icpp.cpp:14:12: error: no member named 'format' in namespace 'std'
      std::format("v{}.{}.{}.{}", version_major, version_minor, version_patch,
      ~~~~~^
1 error generated.
make[3]: *** [src/CMakeFiles/icpp.dir/icpp.cpp.o] Error 1
make[3]: *** Waiting for unfinished jobs....
In file included from /Users/yongwei/Programming/icpp/src/log.cppIn file included from :7/Users/yongwei/Programming/icpp/src/debugger.cpp:
:7:
In file included from /Users/yongwei/Programming/icpp/src/log.h/Users/yongwei/Programming/icpp/src/debugger.h::2610::
42In file included from :/Users/yongwei/Programming/icpp/src/utils.h :9:
error: no template named 'format_string' in namespace 'std'
/Users/yongwei/Programming/icpp/src/log.h:26:42: error: no template named 'format_string' in namespace 'std'
inline void log_print(LogType type, std::format_string<Args...> format,
                                    ~~~~~^
inline void log_print(LogType type, std::format_string<Args...> format,
                                    ~~~~~^
In file included from /Users/yongwei/Programming/icpp/src/loader.cpp:10:
/Users/yongwei/Programming/icpp/src/log.h:26:42: error: no template named 'format_string' in namespace 'std'
inline void log_print(LogType type, std::format_string<Args...> format,
                                    ~~~~~^
In file included from /Users/yongwei/Programming/icpp/src/exec.cpp:9:
In file included from /Users/yongwei/Programming/icpp/src/debugger.h:10:
In file included from /Users/yongwei/Programming/icpp/src/utils.h:9:
/Users/yongwei/Programming/icpp/src/log.h:26:42: error: no template named 'format_string' in namespace 'std'
inline void log_print(LogType type, std::format_string<Args...> format,
                                    ~~~~~^
…

This looks much more normal. Maybe you do not have to use std::format? Maybe just use fmtlib instead?

BTW, the same repo directory worked in Linux (with different build directories). The build was smooth and successful.

@GeekNeo
Copy link
Contributor

GeekNeo commented Aug 6, 2024

Your clang within Xcode is too old to support C++20, updating to the latest Xcode will fix your compilation error.

@adah1972
Copy link
Author

adah1972 commented Aug 6, 2024

Your clang within Xcode is too old to support C++20, updating to the latest Xcode will fix your compilation error.

I understand it cannot fully support C++20, but that is the latest version available for Ventura.

@adah1972
Copy link
Author

adah1972 commented Aug 6, 2024

Also, the README said "before the version of macOS 11". I am already at 13, but the Apple Clang available from Apple still does not work. So the documentation is not very precise, either.

If you want people on Ventura/Monterey to use icpp, you had better either provide binaries (this also solves the installation issue I mentioned in issue #3), or make the code compatible with earlier Apple Clang releases. This is the smoother path. Or solve the main issue here: make building with the bundled Clang work.

I would guess that switching to fmtlib would be easier than solving the weird build issue here.

@GeekNeo
Copy link
Contributor

GeekNeo commented Aug 6, 2024

If your system default clang doesn't support C++20 before the version of macOS 14, you should compile your own clang and apply it like on Linux.

This is a very complicated process. So I strongly recommend that you update your macOS and Xcode to the latest version to have the C++20 support to simplify the building.

@GeekNeo GeekNeo closed this as completed Aug 7, 2024
@adah1972
Copy link
Author

adah1972 commented Aug 8, 2024

Hi, the main issue was exactly the Linux steps did not work on macOS!!!

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