@@ -9,23 +9,19 @@ option(USE_OMP "Use OpenMP as backend for Eigen" ON)
99option (USE_NCCL "Build project for distributed running on CUDA using NCCL" ON )
1010option (USE_MCCL "Build project for distributed running on MACA using MCCL" ON )
1111
12- # ------------------------------------------------------------------------------
13- # MACA toolchain override (must happen before project())
14- # ------------------------------------------------------------------------------
15- # When targeting MetaX MACA, the C/C++ compiler must be mxcc so that .maca
16- # sources and device code can be compiled by the MACA toolchain.
12+ project (infini_train VERSION 0.5.0 LANGUAGES CXX )
13+
14+ # Switch to mxcc after project() so that third-party libs (glog, gflags) are
15+ # configured with the host compiler and their feature-detection checks pass.
1716if (USE_MACA)
1817 set (MACA_PATH $ENV{MACA_PATH} )
1918 if (NOT MACA_PATH)
20- message (FATAL_ERROR "USE_MACA=ON but environment variable MACA_PATH is not set. "
21- "Please export MACA_PATH (e.g. /opt/maca) before configuring." )
19+ message (FATAL_ERROR "USE_MACA=ON but environment variable MACA_PATH is not set." )
2220 endif ()
2321 set (CMAKE_C_COMPILER "${MACA_PATH} /mxgpu_llvm/bin/mxcc" )
2422 set (CMAKE_CXX_COMPILER "${MACA_PATH} /mxgpu_llvm/bin/mxcc" )
2523endif ()
2624
27- project (infini_train VERSION 0.5.0 LANGUAGES CXX )
28-
2925set (CMAKE_CXX_STANDARD 20)
3026set (CMAKE_CXX_STANDARD_REQUIRED ON )
3127set (CMAKE_CXX_EXTENSIONS OFF )
@@ -45,45 +41,8 @@ include_directories(${gflags_SOURCE_DIR}/include)
4541set (WITH_GFLAGS OFF CACHE BOOL "Disable glog finding system gflags" FORCE )
4642set (WITH_GTEST OFF CACHE BOOL "Disable glog finding system gtest" FORCE )
4743set (BUILD_TESTING OFF CACHE BOOL "Disable glog unit tests" FORCE )
48- # Build glog as a static lib so its symbols are always visible at link time.
49- # Under mxcc the default symbol visibility is hidden, which causes the shared
50- # libglog.so to export no symbols and produces "undefined reference" errors.
5144set (BUILD_SHARED_LIBS OFF CACHE BOOL "Build glog as static library" FORCE )
5245
53- # Under MACA/mxcc, cmake's feature-detection test compilations do not find
54- # standard POSIX system headers (mxcc has a non-standard sysroot probe path).
55- # Pre-set glog's HAVE_* cache variables so that glog skips its fallback type /
56- # symbol definitions, which would otherwise conflict with the real system
57- # headers during the actual build.
58- if (USE_MACA)
59- set (HAVE_SYS_TYPES_H 1 CACHE INTERNAL "" )
60- set (HAVE_UNISTD_H 1 CACHE INTERNAL "" )
61- set (HAVE_DLFCN_H 1 CACHE INTERNAL "" )
62- set (HAVE_GLOB_H 1 CACHE INTERNAL "" )
63- set (HAVE_PWD_H 1 CACHE INTERNAL "" )
64- set (HAVE_SYS_TIME_H 1 CACHE INTERNAL "" )
65- set (HAVE_SYS_UTSNAME_H 1 CACHE INTERNAL "" )
66- set (HAVE_SYS_WAIT_H 1 CACHE INTERNAL "" )
67- set (HAVE_SYS_SYSCALL_H 1 CACHE INTERNAL "" )
68- set (HAVE_SYSLOG_H 1 CACHE INTERNAL "" )
69- set (HAVE_UCONTEXT_H 1 CACHE INTERNAL "" )
70- # check_type_size() uses two internal variables: the size value and a sentinel
71- # "HAVE_HAVE_<VAR>" that marks the check as done. Pre-setting only the value
72- # is insufficient — the sentinel must also be set so the check skips entirely.
73- set (HAVE_MODE_T 4 CACHE INTERNAL "" ) # 4 bytes on Linux
74- set (HAVE_HAVE_MODE_T TRUE CACHE INTERNAL "" )
75- set (HAVE_SSIZE_T 8 CACHE INTERNAL "" ) # 8 bytes on 64-bit Linux
76- set (HAVE_HAVE_SSIZE_T TRUE CACHE INTERNAL "" )
77- set (HAVE_PREAD 1 CACHE INTERNAL "" )
78- set (HAVE_PWRITE 1 CACHE INTERNAL "" )
79- set (HAVE_POSIX_FADVISE 1 CACHE INTERNAL "" )
80- set (HAVE_SIGACTION 1 CACHE INTERNAL "" )
81- set (HAVE_SIGALTSTACK 1 CACHE INTERNAL "" )
82- set (HAVE_FCNTL 1 CACHE INTERNAL "" )
83- set (HAVE_DLADDR 1 CACHE INTERNAL "" )
84- set (HAVE___CXA_DEMANGLE 1 CACHE INTERNAL "" )
85- endif ()
86-
8746add_subdirectory (third_party/glog )
8847include_directories (${glog_SOURCE_DIR} /src )
8948
0 commit comments