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

Issues while building for MacOS M2 with CMake #13756

Open
buhtr opened this issue Jan 23, 2025 · 0 comments
Open

Issues while building for MacOS M2 with CMake #13756

buhtr opened this issue Jan 23, 2025 · 0 comments
Labels

Comments

@buhtr
Copy link

buhtr commented Jan 23, 2025

Built ydb for MacOS M2 using CMake as I am not familiar with Yatool yet.

The build host is:

Darwin 22.6.0 Darwin Kernel Version 22.6.0: Sun Dec 17 22:13:25 PST 2023; root:xnu-8796.141.3.703.2~2/RELEASE_ARM64_T6020 arm64

To allow this to happen the following errors has been fixed:

  1. Changed ar to llvm-ar in a file clang.toolchain
set(CMAKE_AR llvm-ar)

As ar failed to correctly create static libs.

  1. In a file cmake/FindAIO.cmake commented search for libaio, as it does not supported by MacOS. This changes do not affected on a build process but may be it affects on a run ? Ydbd seems to start fine after build.
#find_path(AIO_INCLUDE_DIR
#  libaio.h
#  HINTS $ENV{AIO_ROOT}/include /usr/include REQUIRED)

#find_library(AIO_LIBRARIES
#  aio
#  HINTS $ENV{AIO_ROOT}/lib REQUIRED)
  1. The file contrib/libs/cxxsupp/builtins/aarch64/sme-libc-routines.c applies _arm_streaming_compatible, but this keyword has appeared only in a clang-18. Just commented it.

  2. The lib contrib/libs/openldap/ does not fix problem with gethostbyname_r. MacOS does not have such function in a glibc.
    Created contrib/libs/openldap/include/portable-osx.h. And changed portable.h to

#pragma once

#if defined(__APPLE__)
#   include "portable-osx.h"
#else
#   include "portable-linux.h"
#endif

#if defined(_musl_)
#   include "portable-musl.h"
#endif
  1. Several CMake files for libs contain the following code
target_link_options(restricted-aws-aws-c-cal INTERFACE
  -framework
  Security
)

CMake Probably removes duplicates and this leads to put in a LINK_FLAGS just "Security" without "-framework". In order to fix this the keyword "SHELL" is applied:

target_link_options(restricted-aws-aws-c-cal INTERFACE "SHELL:-framework Security")

Fixed in the following files:

  • contrib/libs/curl/CMakeLists.darwin-arm64.txt (SystemConfiguration)
  • contrib/restricted/aws/aws-c-cal/CMakeLists.darwin-arm64.txt (Security)
  1. Installed locally correct version of antrl

  2. The libxml uses iconv but does not provide target_link_options for it, just added it

  3. After all ydbd is built and can be started.

  4. Ydb linked with llvm14 from contrib but in a config the clang-16 is a compiler. Do not have any issues with it just curious may be it need to be switched on llvm16 ?

As your main build tool is Yatool and it is used to build CMake files I am not sure how to create a PR for this issues. Feel free to write me back if such PR will be valuable for your.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants