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

Building from source failed on mac M1 #5184

Closed
Cerdore opened this issue Jun 21, 2022 · 21 comments
Closed

Building from source failed on mac M1 #5184

Cerdore opened this issue Jun 21, 2022 · 21 comments
Labels
type/bug The issue is confirmed as a bug. type/question The issue belongs to a question.

Comments

@Cerdore
Copy link

Cerdore commented Jun 21, 2022

Hello!

I try to build tiflash from source on my mac m1, and I got some errors when configuring.

When I run cmake ../tiflash, I got CMake Error at contrib/zlib-ng/CMakeLists.txt:477 (message): sizeof(void *) is neither 32 nor 64 bit. And I also found this error in there(ClickHouse repo), so I follow this issue to modify the CMakeLists.

if (USE_STATIC_LIBRARIES AND HAVE_NO_PIE)
#    set (CMAKE_CXX_FLAGS                 "${CMAKE_CXX_FLAGS} ${FLAG_NO_PIE}")
#    set (CMAKE_C_FLAGS                   "${CMAKE_C_FLAGS} ${FLAG_NO_PIE}")
    set (CMAKE_CXX_FLAGS                 "${CMAKE_CXX_FLAGS}")
    set (CMAKE_C_FLAGS                   "${CMAKE_C_FLAGS}")
endif ()

But it does not work...

In case it's a problem with xcode CommandLineTools, I also reinstalled xcode-select.

@Cerdore Cerdore added the type/question The issue belongs to a question. label Jun 21, 2022
@Cerdore
Copy link
Author

Cerdore commented Jun 21, 2022

Here is the output of cmake ../tiflash . And here are many hints of failed detection...


➜  tiflashBuild cmake ../tiflash
-- The C compiler identification is AppleClang 13.0.0.13000027
-- The CXX compiler identification is AppleClang 13.0.0.13000027
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using CXX=/Library/Developer/CommandLineTools/usr/bin/c++, ver=13.0.0.13000027;CC=/Library/Developer/CommandLineTools/usr/bin/cc, ver=13.0.0.13000027
-- Not using ccache CCACHE_FOUND-NOTFOUND, USE_CCACHE=ON
-- CMAKE_BUILD_TYPE is not set, set to default = RelWithDebInfo
-- CMAKE_BUILD_TYPE: RelWithDebInfo
-- Using linker: lld (selected from: LLD_PATH=/opt/homebrew/opt/llvm/bin/lld; GOLD_PATH=GOLD_PATH-NOTFOUND; COMPILER_POSTFIX=)
-- Performing Test HAVE_SSE41
-- Performing Test HAVE_SSE41 - Failed
-- Performing Test HAVE_SSE42
-- Performing Test HAVE_SSE42 - Failed
-- Performing Test HAVE_POPCNT
-- Performing Test HAVE_POPCNT - Failed
-- Performing Test HAVE_LIBCXX
-- Performing Test HAVE_LIBCXX - Failed
-- Building for: Darwin-21.3.0 arm64  ; USE_STATIC_LIBRARIES=ON MAKE_STATIC_LIBRARIES=ON UNBUNDLED=OFF
-- Using ssl=1: /Users/dd/gitRepo/DBPrototype/tiflash/contrib/boringssl/include : ssl;crypto
-- Build without ICU (support for collations and charset conversion functions will be disabled)
-- Using Boost: /Users/dd/gitRepo/DBPrototype/tiflash/contrib/boost : boost_internal,boost_internal,boost_internal
-- Using zlib: /Users/dd/gitRepo/DBPrototype/tiflash/contrib/zlib-ng;/Users/dd/gitRepo/DBPrototype/tiflashBuild/contrib/zlib-ng : zlibstatic
-- Using zstd:  : zstd
-- Using Poco: /Users/dd/gitRepo/DBPrototype/tiflash/contrib/poco/Foundation/include/;/Users/dd/gitRepo/DBPrototype/tiflash/contrib/poco/Util/include/;/Users/dd/gitRepo/DBPrototype/tiflash/contrib/zlib-ng/;/Users/dd/gitRepo/DBPrototype/tiflashBuild/contrib/zlib-ng/ : PocoFoundation,PocoUtil,PocoNet,PocoNetSSL,PocoXML,PocoData,,PocoMongoDB; MongoDB=1, DataODBC=, NetSSL=1
-- Using lz4: /Users/dd/gitRepo/DBPrototype/tiflash/contrib/lz4/lib : lz4
-- Using sparsehash: /Users/dd/gitRepo/DBPrototype/tiflash/contrib/libsparsehash
-- Using rt: apple_rt
-- Not using any library for line editing.
-- Using re2: /Users/dd/gitRepo/DBPrototype/tiflash/contrib/re2 : re2;  : re2_st
-- Using protobuf:  :  : /Users/dd/gitRepo/DBPrototype/tiflash/contrib/protobuf/src, libprotobuf, $<TARGET_FILE:protoc>
-- Using gRPC: 1 :  : /Users/dd/gitRepo/DBPrototype/tiflash/contrib/grpc/include, grpc;grpc++, $<TARGET_FILE:grpc_cpp_plugin>
-- Using kvproto: /Users/dd/gitRepo/DBPrototype/tiflash/contrib/kvproto/cpp
-- Using tipb: /Users/dd/gitRepo/DBPrototype/tiflash/contrib/tipb/cpp
-- Using curl: 1 : /Users/dd/gitRepo/DBPrototype/tiflash/contrib/curl/include, libcurl
-- Using prometheus: /Users/dd/gitRepo/DBPrototype/tiflash/contrib/prometheus-cpp
-- Using tiflash proxy: 1 : /Users/dd/gitRepo/DBPrototype/tiflash/contrib/tiflash-proxy/raftstore-proxy/ffi/src, libtiflash_proxy
-- Performing Test CFLAG_Wall
-- Performing Test CFLAG_Wall - Failed
-- Performing Test CFLAG_Wextra
-- Performing Test CFLAG_Wextra - Failed
-- Performing Test CFLAG_Wcast_qual
-- Performing Test CFLAG_Wcast_qual - Failed
-- Performing Test CFLAG_Wcast_align
-- Performing Test CFLAG_Wcast_align - Failed
-- Performing Test CFLAG_Wshadow
-- Performing Test CFLAG_Wshadow - Failed
-- Performing Test CFLAG_Wstrict_aliasing_1
-- Performing Test CFLAG_Wstrict_aliasing_1 - Failed
-- Performing Test CFLAG_Wswitch_enum
-- Performing Test CFLAG_Wswitch_enum - Failed
-- Performing Test CFLAG_Wdeclaration_after_statement
-- Performing Test CFLAG_Wdeclaration_after_statement - Failed
-- Performing Test CFLAG_Wstrict_prototypes
-- Performing Test CFLAG_Wstrict_prototypes - Failed
-- Performing Test CFLAG_Wundef
-- Performing Test CFLAG_Wundef - Failed
-- Using cityhash: /Users/dd/gitRepo/DBPrototype/tiflash/contrib/libcityhash/include : cityhash
-- Using farmhash:  : farmhash
-- Using metrohash:  : metrohash
-- Using btrie:  : btrie
-- Using double-conversion: /Users/dd/gitRepo/DBPrototype/tiflash/contrib/double-conversion : double-conversion
-- Performing Test HAVE_UNWIND_INIT_LOCAL_SIGNAL
-- Performing Test HAVE_UNWIND_INIT_LOCAL_SIGNAL - Failed
-- Using unwind=:  :
-- Using tcmalloc=1: /Users/dd/gitRepo/DBPrototype/tiflash/contrib/libtcmalloc/include : tcmalloc_minimal_internal
-- Using cctz: /Users/dd/gitRepo/DBPrototype/tiflash/contrib/cctz/include : cctz
-- compiler C   = /Library/Developer/CommandLineTools/usr/bin/cc    -pipe -fno-omit-frame-pointer  -Wall -Wno-unused-command-line-argument   -O2 -g -DNDEBUG
-- compiler CXX = /Library/Developer/CommandLineTools/usr/bin/c++  -D__GLIBCXX_BITSIZE_INT_N_0=128 -D__GLIBCXX_TYPE_INT_N_0=__int128   -pipe  -fno-omit-frame-pointer  -Wall -Wno-unused-command-line-argument  -Wnon-virtual-dtor  -O2 -g -DNDEBUG
-- LINKER_FLAGS = -L/opt/homebrew/opt/llvm/lib -fuse-ld=lld
-- Boost.Context: architecture arm64, binary format mach-o, ABI aapcs, assembler gas, suffix .S, implementation fcontext
-- The ASM compiler identification is Clang with GNU-like command-line
-- Found assembler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Boost.Fiber: NUMA target OS is none
-- ZSTD VERSION 1.5.0
-- Using CMake version 3.22.1
-- ZLIB_HEADER_VERSION: 1.2.11
-- ZLIBNG_HEADER_VERSION: 2.0.6
-- Arch detected: 'aarch64'
-- Basearch of 'aarch64' has been detected as: 'arm'
-- Performing Test FNO_LTO_AVAILABLE
-- Performing Test FNO_LTO_AVAILABLE - Failed
-- Architecture supports unaligned reads
-- Architecture supports unaligned reads of > 4 bytes
-- Looking for sys/sdt.h
-- Looking for sys/sdt.h - not found
-- Looking for unistd.h
-- Looking for unistd.h - not found
-- Looking for sys/types.h
-- Looking for sys/types.h - not found
-- Looking for stdint.h
-- Looking for stdint.h - not found
-- Looking for stddef.h
-- Looking for stddef.h - not found
-- Check size of off64_t
-- Check size of off64_t - failed
-- Check size of _off64_t
-- Check size of _off64_t - failed
-- Check size of __off64_t
-- Check size of __off64_t - failed
-- Looking for fseeko
-- Looking for fseeko - not found
-- Looking for strerror
-- Looking for strerror - not found
-- Looking for posix_memalign
-- Looking for posix_memalign - not found
-- Performing Test HAVE_NO_INTERPOSITION
-- Performing Test HAVE_NO_INTERPOSITION - Failed
-- Performing Test HAVE_ATTRIBUTE_VISIBILITY_HIDDEN
-- Performing Test HAVE_ATTRIBUTE_VISIBILITY_HIDDEN - Failed
-- Performing Test HAVE_ATTRIBUTE_VISIBILITY_INTERNAL
-- Performing Test HAVE_ATTRIBUTE_VISIBILITY_INTERNAL - Failed
-- Performing Test HAVE_BUILTIN_CTZ
-- Performing Test HAVE_BUILTIN_CTZ - Failed
-- Performing Test HAVE_BUILTIN_CTZLL
-- Performing Test HAVE_BUILTIN_CTZLL - Failed
-- Performing Test HAVE_PTRDIFF_T
-- Performing Test HAVE_PTRDIFF_T - Failed
-- Check size of void *
-- Check size of void * - failed
-- sizeof(void *) is  bytes
CMake Error at contrib/zlib-ng/CMakeLists.txt:477 (message):
  sizeof(void *) is neither 32 nor 64 bit


-- Configuring incomplete, errors occurred!
See also "/Users/dd/gitRepo/DBPrototype/tiflashBuild/CMakeFiles/CMakeOutput.log".
See also "/Users/dd/gitRepo/DBPrototype/tiflashBuild/CMakeFiles/CMakeError.log".

@Cerdore
Copy link
Author

Cerdore commented Jun 21, 2022

➜  tiflashBuild cmake --version
cmake version 3.22.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).
➜  tiflashBuild python --version
Python 3.8.9

➜  tiflashBuild clang --version
Homebrew clang version 13.0.1
Target: arm64-apple-darwin21.3.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin

openssl@1.1

@Cerdore
Copy link
Author

Cerdore commented Jun 21, 2022

CMakeError.log

There are many hints of identifier errors. I also found some discussion about this question but no solution...

In file included from /Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/include/xmmintrin.h:13:
/Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/include/mmintrin.h:33:5: error: use of undeclared identifier '__builtin_ia32_emms'; did you mean '__builtin_isless'?
    __builtin_ia32_emms();
    ^
/Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/include/mmintrin.h:33:5: note: '__builtin_isless' declared here
/Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/include/mmintrin.h:33:25: error: too few arguments to function call, expected 2, have 0
    __builtin_ia32_emms();
    ~~~~~~~~~~~~~~~~~~~~^
/Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/include/mmintrin.h:50:19: error: use of undeclared identifier '__builtin_ia32_vec_init_v2si'
    return (__m64)__builtin_ia32_vec_init_v2si(__i, 0);
...

Changing CMakeLists also dose not work..

option (ARCHNATIVE "Enable -march=native compiler flag" OFF)
if (ARCHNATIVE)
#    set (COMPILER_FLAGS                  "${COMPILER_FLAGS} -march=native")
    set (COMPILER_FLAGS                  "${COMPILER_FLAGS}")
endif ()

@SchrodingerZhu
Copy link
Contributor

Hi, do you have more detailed inclusion path of immintrin.h? It is strange to be included on ARM platform.

@Cerdore
Copy link
Author

Cerdore commented Jun 22, 2022

Hi, do you have more detailed inclusion path of immintrin.h? It is strange to be included on ARM platform.

Hi~
The path of immintrin.h: /Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/include/mmintrin.h.
It looks like xcode-select comes with.

@Cerdore
Copy link
Author

Cerdore commented Jun 22, 2022

I may have found a solution, I'll try it.
image

@SchrodingerZhu
Copy link
Contributor

Sorry for the confusion, by saying inclusion path, I mean would you provide the inclusion tree of the file, like
a.cpp includes a.h, a.h includes immintrin.h.

This can be inferred from the error context.

In file included from /Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/include/xmmintrin.h:13:
/Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/include/mmintrin.h:33:5: error: use of undeclared identifier '__builtin_ia32_emms'; did you mean '__builtin_isless'?
    __builtin_ia32_emms();
    ^
/Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/include/mmintrin.h:33:5: note: '__builtin_isless' declared here
/Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/include/mmintrin.h:33:25: error: too few arguments to function call, expected 2, have 0
    __builtin_ia32_emms();
    ~~~~~~~~~~~~~~~~~~~~^
/Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/include/mmintrin.h:50:19: error: use of undeclared identifier '__builtin_ia32_vec_init_v2si'
    return (__m64)__builtin_ia32_vec_init_v2si(__i, 0);
...

so is it possible to provide what you have omitted here?

@Cerdore
Copy link
Author

Cerdore commented Jun 22, 2022

Hi, do you have more detailed inclusion path of immintrin.h? It is strange to be included on ARM platform.

I think here's the problem. And the parameter "msse4.1" appears...

Run Build Command(s):/usr/bin/make -f Makefile cmTC_1148d/fast && /Library/Developer/CommandLineTools/usr/bin/make  -f CMakeFiles/cmTC_1148d.dir/build.make CMakeFiles/cmTC_1148d.dir/build
Building CXX object CMakeFiles/cmTC_1148d.dir/src.cxx.o
/opt/homebrew/opt/llvm/bin/clang++ -DHAVE_SSE41  -D__GLIBCXX_BITSIZE_INT_N_0=128 -D__GLIBCXX_TYPE_INT_N_0=__int128 -msse4.1 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk -mmacosx-version-min=12.2 -MD -MT CMakeFiles/cmTC_1148d.dir/src.cxx.o -MF CMakeFiles/cmTC_1148d.dir/src.cxx.o.d -o CMakeFiles/cmTC_1148d.dir/src.cxx.o -c /Users/chenxiansen/gitRepo/DBPrototype/tiflashBuild/CMakeFiles/CMakeTmp/src.cxx
clang-13: warning: argument unused during compilation: '-msse4.1' [-Wunused-command-line-argument]
In file included from /Users/chenxiansen/gitRepo/DBPrototype/tiflashBuild/CMakeFiles/CMakeTmp/src.cxx:2

And I found 'msse4.1' in cmake/test_cpu.cmake... So I think it doesn't matter here.

set (TEST_FLAG "-msse4.1")
set (CMAKE_REQUIRED_FLAGS "${TEST_FLAG}")
check_cxx_source_compiles("
    #include <smmintrin.h>
    int main() {
        _mm_insert_epi8(__m128i(), 0, 0);
        return 0;
    }
" HAVE_SSE41)
if (HAVE_SSE41)
    set (COMPILER_FLAGS "${COMPILER_FLAGS} ${TEST_FLAG}")
endif ()

@SchrodingerZhu
Copy link
Contributor

Hi, do you have more detailed inclusion path of immintrin.h? It is strange to be included on ARM platform.

I think here's the problem. May contrib/zlib-ng used the intel compile option. And the parameter "msse4.1" appears...

Run Build Command(s):/usr/bin/make -f Makefile cmTC_1148d/fast && /Library/Developer/CommandLineTools/usr/bin/make  -f CMakeFiles/cmTC_1148d.dir/build.make CMakeFiles/cmTC_1148d.dir/build
Building CXX object CMakeFiles/cmTC_1148d.dir/src.cxx.o
/opt/homebrew/opt/llvm/bin/clang++ -DHAVE_SSE41  -D__GLIBCXX_BITSIZE_INT_N_0=128 -D__GLIBCXX_TYPE_INT_N_0=__int128 -msse4.1 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk -mmacosx-version-min=12.2 -MD -MT CMakeFiles/cmTC_1148d.dir/src.cxx.o -MF CMakeFiles/cmTC_1148d.dir/src.cxx.o.d -o CMakeFiles/cmTC_1148d.dir/src.cxx.o -c /Users/chenxiansen/gitRepo/DBPrototype/tiflashBuild/CMakeFiles/CMakeTmp/src.cxx
clang-13: warning: argument unused during compilation: '-msse4.1' [-Wunused-command-line-argument]
In file included from /Users/chenxiansen/gitRepo/DBPrototype/tiflashBuild/CMakeFiles/CMakeTmp/src.cxx:2

Yes, that is quite suspicious.

@Cerdore
Copy link
Author

Cerdore commented Jun 22, 2022

Hi, do you have more detailed inclusion path of immintrin.h? It is strange to be included on ARM platform.

I think here's the problem. May contrib/zlib-ng used the intel compile option. And the parameter "msse4.1" appears...

Run Build Command(s):/usr/bin/make -f Makefile cmTC_1148d/fast && /Library/Developer/CommandLineTools/usr/bin/make  -f CMakeFiles/cmTC_1148d.dir/build.make CMakeFiles/cmTC_1148d.dir/build
Building CXX object CMakeFiles/cmTC_1148d.dir/src.cxx.o
/opt/homebrew/opt/llvm/bin/clang++ -DHAVE_SSE41  -D__GLIBCXX_BITSIZE_INT_N_0=128 -D__GLIBCXX_TYPE_INT_N_0=__int128 -msse4.1 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk -mmacosx-version-min=12.2 -MD -MT CMakeFiles/cmTC_1148d.dir/src.cxx.o -MF CMakeFiles/cmTC_1148d.dir/src.cxx.o.d -o CMakeFiles/cmTC_1148d.dir/src.cxx.o -c /Users/chenxiansen/gitRepo/DBPrototype/tiflashBuild/CMakeFiles/CMakeTmp/src.cxx
clang-13: warning: argument unused during compilation: '-msse4.1' [-Wunused-command-line-argument]
In file included from /Users/chenxiansen/gitRepo/DBPrototype/tiflashBuild/CMakeFiles/CMakeTmp/src.cxx:2

Yes, that is quite suspicious.

I found 'msse4.1' in cmake/test_cpu.cmake... So I think it doesn't matter here...

I used AppleClang back and restored my changes in CMakeLists.txt. After deleting the content of test_cpu.cmake, I reconfigure the project and got some error :

ld64.lld: error: LC_DYLD_INFO_ONLY not found in /opt/homebrew/opt/llvm/lib/libunwind.dylib
clang: error: linker command failed with exit code 1 (use -v to see invocation)

full information:

Run Build Command(s):/usr/bin/make -f Makefile cmTC_863a3/fast && /Library/Developer/CommandLineTools/usr/bin/make  -f CMakeFiles/cmTC_863a3.dir/build.make CMakeFiles/cmTC_863a3.dir/build
Building CXX object CMakeFiles/cmTC_863a3.dir/src.cxx.o
/Library/Developer/CommandLineTools/usr/bin/c++ -DHAVE_LIBCXX  -D__GLIBCXX_BITSIZE_INT_N_0=128 -D__GLIBCXX_TYPE_INT_N_0=__int128   -pipe  -fno-omit-frame-pointer  -Wall -Wno-unused-command-line-argument  -Wnon-virtual-dtor  -Wl,-Bstatic -stdlib=libc++ -lc++ -lc++abi -Wl,-Bdynamic -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk -mmacosx-version-min=12.2 -std=gnu++17 -MD -MT CMakeFiles/cmTC_863a3.dir/src.cxx.o -MF CMakeFiles/cmTC_863a3.dir/src.cxx.o.d -o CMakeFiles/cmTC_863a3.dir/src.cxx.o -c /Users/chenxiansen/gitRepo/DBPrototype/tiflashBuild/CMakeFiles/CMakeTmp/src.cxx
Linking CXX executable cmTC_863a3
/opt/homebrew/Cellar/cmake/3.22.1/bin/cmake -E cmake_link_script CMakeFiles/cmTC_863a3.dir/link.txt --verbose=1
/Library/Developer/CommandLineTools/usr/bin/c++  -D__GLIBCXX_BITSIZE_INT_N_0=128 -D__GLIBCXX_TYPE_INT_N_0=__int128   -pipe  -fno-omit-frame-pointer  -Wall -Wno-unused-command-line-argument  -Wnon-virtual-dtor  -Wl,-Bstatic -stdlib=libc++ -lc++ -lc++abi -Wl,-Bdynamic -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk -mmacosx-version-min=12.2 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -L/opt/homebrew/opt/llvm/lib -fuse-ld=lld  CMakeFiles/cmTC_863a3.dir/src.cxx.o -o cmTC_863a3
ld64.lld: error: unknown argument '-Bstatic', did you mean '-static'
ld64.lld: error: unknown argument '-Bdynamic', did you mean '-dynamic'
ld64.lld: error: LC_DYLD_INFO_ONLY not found in /opt/homebrew/opt/llvm/lib/libc++.dylib
ld64.lld: error: LC_DYLD_INFO_ONLY not found in /opt/homebrew/opt/llvm/lib/libc++abi.dylib
ld64.lld: error: LC_DYLD_INFO_ONLY not found in /opt/homebrew/opt/llvm/lib/libunwind.dylib
ld64.lld: error: undefined symbol: std::__1::cerr
>>> referenced by CMakeFiles/cmTC_863a3.dir/src.cxx.o

ld64.lld: error: undefined symbol: std::__1::cerr
>>> referenced by CMakeFiles/cmTC_863a3.dir/src.cxx.o

ld64.lld: error: undefined symbol: std::__1::basic_ostream<char, std::__1::char_traits<char> >::flush()
>>> referenced by CMakeFiles/cmTC_863a3.dir/src.cxx.o

ld64.lld: error: undefined symbol: std::__1::basic_ostream<char, std::__1::char_traits<char> >::put(char)
>>> referenced by CMakeFiles/cmTC_863a3.dir/src.cxx.o

ld64.lld: error: undefined symbol: __Unwind_Resume
>>> referenced by CMakeFiles/cmTC_863a3.dir/src.cxx.o

ld64.lld: error: undefined symbol: std::__1::locale::~locale()
>>> referenced by CMakeFiles/cmTC_863a3.dir/src.cxx.o

ld64.lld: error: undefined symbol: std::__1::locale::~locale()
>>> referenced by CMakeFiles/cmTC_863a3.dir/src.cxx.o

ld64.lld: error: undefined symbol: std::__1::ios_base::getloc() const
>>> referenced by CMakeFiles/cmTC_863a3.dir/src.cxx.o

ld64.lld: error: undefined symbol: std::__1::locale::use_facet(std::__1::locale::id&) const
>>> referenced by CMakeFiles/cmTC_863a3.dir/src.cxx.o

ld64.lld: error: undefined symbol: std::__1::ctype<char>::id
>>> referenced by CMakeFiles/cmTC_863a3.dir/src.cxx.o

ld64.lld: error: undefined symbol: std::__1::ctype<char>::id
>>> referenced by CMakeFiles/cmTC_863a3.dir/src.cxx.o

ld64.lld: error: undefined symbol: ___gxx_personality_v0
>>> referenced by CMakeFiles/cmTC_863a3.dir/src.cxx.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [cmTC_863a3] Error 1
make: *** [cmTC_863a3/fast] Error 2

@SchrodingerZhu
Copy link
Contributor

SchrodingerZhu commented Jun 22, 2022

 -Wl,-Bstatic -stdlib=libc++ -lc++ -lc++abi -Wl,-Bdynamic

This makes the compiler to find static libraries, which is not expected. But it does not take effect as:

ld64.lld: error: unknown argument '-Bstatic', did you mean '-static'
ld64.lld: error: unknown argument '-Bdynamic', did you mean '-dynamic'

@SchrodingerZhu
Copy link
Contributor

https://github.com/pingcap/tiflash/blob/master/CMakeLists.txt#L274, would you check if this code block is wrongly executed?

e.g. adding message(FATAL_ERROR "this should not be executed") inside?

@Cerdore
Copy link
Author

Cerdore commented Jun 22, 2022

I found this issue, Byron mentioned

llvms ldd did seem to work, but has problems finding LC_DYLD_INFO_ONLY, which apparently has disappeared in favor of a new format, somehow.

@Cerdore
Copy link
Author

Cerdore commented Jun 22, 2022

https://github.com/pingcap/tiflash/blob/master/CMakeLists.txt#L274, would you check if this code block is wrongly executed?

e.g. adding message(FATAL_ERROR "this should not be executed") inside?

This code block is not executed.

@Cerdore
Copy link
Author

Cerdore commented Jun 22, 2022

I found this issue, Byron mentioned

llvms ldd did seem to work, but has problems finding LC_DYLD_INFO_ONLY, which apparently has disappeared in favor of a new format, somehow.

This problem seems to be caused by llvm. I would like to ask if anyone has successfully compiled tiflash with m1?

@SchrodingerZhu
Copy link
Contributor

our CD pipelines compile tiflash for M1. But it is triggered only when we are to release new binaries.

@solotzg Do you have any idea of what is happening here?

@Cerdore
Copy link
Author

Cerdore commented Jun 22, 2022

I have solved this issue. I want create a pr about modifying the CMakeList later. Is this okay?

our CD pipelines compile tiflash for M1. But it is triggered only when we are to release new binaries.

@solotzg Do you have any idea of what is happening here?

@Cerdore
Copy link
Author

Cerdore commented Jun 22, 2022

The problem lies in LINKER_NAME and CMAKE_EXE_LINKER_FLAGS. When I use AppleClang, if CMAKE_EXE_LINKER_FLAGS finds the lld of llvm then I get an error.

@SchrodingerZhu
Copy link
Contributor

Feel free to have a try!

@SchrodingerZhu SchrodingerZhu added the type/bug The issue is confirmed as a bug. label Jun 22, 2022
@Cerdore
Copy link
Author

Cerdore commented Jun 22, 2022

Feel free to have a try!

Thanks for helping me find the problem. I have submitted a solution. PTAL :)

@Cerdore
Copy link
Author

Cerdore commented Jul 13, 2022

Sorry, some time ago I found out that the problem was with my configuration file (.zshrc), which imported an environment variable about llvm.

@Cerdore Cerdore closed this as completed Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug The issue is confirmed as a bug. type/question The issue belongs to a question.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants