Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,19 @@ jobs:
- os: macos-15
platform: macos-arm64
arch_flag: "" # ARM64 uses auto-detection
compiler: default
- os: ubuntu-24.04-arm
platform: linux-arm64
arch_flag: "" # ARM64 uses auto-detection
compiler: default
- os: ubuntu-24.04
platform: linux-x64
arch_flag: "" # Use native CPU microarchitecture
compiler: default
- os: ubuntu-24.04
platform: linux-x64-clang
arch_flag: ""
compiler: clang

steps:
- name: Checkout code
Expand All @@ -101,6 +108,15 @@ jobs:
cache: 'pip'
cache-dependency-path: 'pyproject.toml'

- name: Install Clang
if: matrix.compiler == 'clang'
run: |
sudo apt-get update
sudo apt-get install -y clang
echo "CC=clang" >> $GITHUB_ENV
echo "CXX=clang++" >> $GITHUB_ENV
shell: bash

- name: Set up environment variables
run: |
# Set number of processors for parallel builds
Expand Down Expand Up @@ -139,6 +155,9 @@ jobs:
${{ matrix.arch_flag }}
shell: bash

- name: Setup tmate session
uses: mxschmitt/action-tmate@v3

- name: Run C++ Tests
run: |
cd "$GITHUB_WORKSPACE/build"
Expand All @@ -151,6 +170,7 @@ jobs:
python -m pytest python/tests/
shell: bash


- name: Run C++ Examples
run: |
cd "$GITHUB_WORKSPACE/examples/c++"
Expand All @@ -160,4 +180,4 @@ jobs:
./db-example
./core-example
./ailego-example
shell: bash
shell: bash
43 changes: 28 additions & 15 deletions cmake/bazel.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,24 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

if(APPLE OR ANDROID)
option(CLANG_USE_LIBCXX "Use libc++ instead of libstdc++" ON)
else()
option(CLANG_USE_LIBCXX "Use libc++ instead of libstdc++" OFF)
endif()

set(CLANG_STDLIB_OPTION "")
if(CLANG_USE_LIBCXX)
set(CLANG_STDLIB_OPTION "-stdlib=libc++")
else()
set(CLANG_STDLIB_OPTION "-stdlib=libstdc++")
endif()

if(NOT MSVC)
# Use color in diagnostics
set(
_COMPILER_FLAGS
"$<$<C_COMPILER_ID:Clang>:-fcolor-diagnostics;-stdlib=libc++>"
"$<$<C_COMPILER_ID:Clang>:-fcolor-diagnostics;${CLANG_STDLIB_OPTION}>"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-stdlib flag incorrectly applied to C compilation

The generator expression $<$<C_COMPILER_ID:Clang>:-fcolor-diagnostics;${CLANG_STDLIB_OPTION}> passes -stdlib=libc++ (or -stdlib=libstdc++) to the C compiler via the $<$<COMPILE_LANGUAGE:C>:...> wrapper a few lines below. The -stdlib flag is meaningful only for C++ compilation; when passed to a C compile unit it is silently ignored by Clang today but may produce a warning with stricter driver flags or future compiler versions.

The C-specific generator expression should only include -fcolor-diagnostics:

Suggested change
"$<$<C_COMPILER_ID:Clang>:-fcolor-diagnostics;${CLANG_STDLIB_OPTION}>"
"$<$<C_COMPILER_ID:Clang>:-fcolor-diagnostics>"

The CXX line (which also uses _COMPILER_FLAGS) can keep ${CLANG_STDLIB_OPTION}. If you want to keep a single variable for the whole block, split it into separate C and CXX variables instead.

"$<$<C_COMPILER_ID:AppleClang>:-fcolor-diagnostics>"
"$<$<C_COMPILER_ID:GNU>:-fdiagnostics-color=always>"
)
Expand Down Expand Up @@ -460,7 +473,7 @@ endif()
# C/C++ strict link flags
set(
BAZEL_CC_STRICT_LINK_FLAGS
"$<$<CXX_COMPILER_ID:Clang>:-stdlib=libc++>"
"$<$<CXX_COMPILER_ID:Clang>:${CLANG_STDLIB_OPTION}>"
${BAZEL_CC_ASAN_COMPILE_FLAGS}
${BAZEL_CC_COVERAGE_COMPILE_FLAGS}
)
Expand All @@ -479,7 +492,7 @@ set(
# C/C++ unstrict link flags
set(
BAZEL_CC_UNSTRICT_LINK_FLAGS
"$<$<CXX_COMPILER_ID:Clang>:-stdlib=libc++>"
"$<$<CXX_COMPILER_ID:Clang>:${CLANG_STDLIB_OPTION}>"
${BAZEL_CC_ASAN_COMPILE_FLAGS}
${BAZEL_CC_COVERAGE_COMPILE_FLAGS}
)
Expand Down Expand Up @@ -572,7 +585,7 @@ function(_targets_link_dependencies _NAME)
if(TARGET ${LIB})
list(APPEND LIBS_DEPS ${LIB})
list(
APPEND LIBS_INCS
APPEND LIBS_INCS
"$<TARGET_PROPERTY:${LIB},INTERFACE_INCLUDE_DIRECTORIES>"
)
endif()
Expand All @@ -590,55 +603,55 @@ function(_target_link_libraries _NAME)
if(NOT _COLLECT_ALWAYS_LINK_VISITED)
set(_COLLECT_ALWAYS_LINK_VISITED "" PARENT_SCOPE)
endif()

set(LOCAL_RESULT "")
foreach(LIB ${LIB_LIST})
if(NOT TARGET ${LIB})
continue()
endif()

list(FIND _COLLECT_ALWAYS_LINK_VISITED ${LIB} ALREADY_VISITED)
if(NOT ALREADY_VISITED EQUAL -1)
continue()
endif()

list(APPEND _COLLECT_ALWAYS_LINK_VISITED ${LIB})
set(_COLLECT_ALWAYS_LINK_VISITED "${_COLLECT_ALWAYS_LINK_VISITED}" PARENT_SCOPE)

get_target_property(ALWAYS_LINK ${LIB} ALWAYS_LINK)
if(ALWAYS_LINK)
list(APPEND LOCAL_RESULT ${LIB})
endif()

get_target_property(DEP_LIBS ${LIB} INTERFACE_LINK_LIBRARIES)
if(DEP_LIBS)
_collect_always_link_libs("${DEP_LIBS}" DEP_ALWAYS_LINK_LIBS)
list(APPEND LOCAL_RESULT ${DEP_ALWAYS_LINK_LIBS})
endif()

get_target_property(LINK_LIBS ${LIB} LINK_LIBRARIES)
if(LINK_LIBS)
_collect_always_link_libs("${LINK_LIBS}" LINK_ALWAYS_LINK_LIBS)
list(APPEND LOCAL_RESULT ${LINK_ALWAYS_LINK_LIBS})
endif()
endforeach()

list(REMOVE_DUPLICATES LOCAL_RESULT)
set(${RESULT_VAR} "${LOCAL_RESULT}" PARENT_SCOPE)
endfunction()

_collect_always_link_libs("${ARGN}" ALL_ALWAYS_LINK_LIBS)

set(ALL_LIBS_TO_PROCESS ${ARGN})
foreach(ALWAYS_LIB ${ALL_ALWAYS_LINK_LIBS})
list(FIND ARGN ${ALWAYS_LIB} FOUND_INDEX)
if(FOUND_INDEX EQUAL -1)
list(APPEND ALL_LIBS_TO_PROCESS ${ALWAYS_LIB})
endif()
endforeach()

list(REMOVE_DUPLICATES ALL_LIBS_TO_PROCESS)

foreach(LIB ${ALL_LIBS_TO_PROCESS})
if(NOT TARGET ${LIB})
list(APPEND LINK_LIBS ${LIB})
Expand Down
Loading