Skip to content

Commit 142ffcb

Browse files
committed
chore: Fix Clang-GCC toolchain libstdc++ linking
refactor: Unify matrix-driven Go setup across CI workflows ci: Unify init script handling across platforms chore: Enforce C++17 and simplify build setup chore: Downgrade Protoc and add CMake policy in CI workflows chore: Downgrade setup-protoc & simplify init scripts chore: Update Protoc version format to include 'v' prefix chore: Align protobuf paths and downgrade setup-protoc chore: Unify protobuf setup across OSes in CI
1 parent 9ea4103 commit 142ffcb

6 files changed

Lines changed: 68 additions & 44 deletions

File tree

.github/workflows/testing-cpp.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,30 @@ jobs:
1818
matrix:
1919
include:
2020
- os: ubuntu-latest
21+
go-version: 1.21.x
22+
init_script: bash init.sh
2123
gen_script: bash gen.sh
22-
cmake_config: cmake -S . -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Debug
2324
run_loader: ./bin/loader
2425
- os: windows-latest
26+
go-version: 1.21.x
27+
init_script: cmd /c init.bat
2528
gen_script: cmd /c gen.bat
26-
cmake_config: cmake -S . -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Debug
2729
run_loader: .\bin\loader.exe
2830

31+
name: test (${{ matrix.os }})
2932
runs-on: ${{ matrix.os }}
3033
timeout-minutes: 10
3134

3235
steps:
3336
- name: Checkout Code
3437
uses: actions/checkout@v6
38+
with:
39+
submodules: recursive
3540

3641
- name: Install Go
3742
uses: actions/setup-go@v6
3843
with:
39-
go-version: 1.21.x
44+
go-version: ${{ matrix.go-version }}
4045
cache: true
4146

4247
- name: Install dependencies (Ubuntu)
@@ -52,16 +57,15 @@ jobs:
5257
uses: ilammy/msvc-dev-cmd@v1
5358

5459
- name: Init submodules and build protobuf
55-
shell: bash
56-
run: bash init.sh
60+
run: ${{ matrix.init_script }}
5761

5862
- name: Generate protoconf
5963
working-directory: test/cpp-tableau-loader
6064
run: ${{ matrix.gen_script }}
6165

6266
- name: CMake Configure
6367
working-directory: test/cpp-tableau-loader
64-
run: ${{ matrix.cmake_config }}
68+
run: cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_STANDARD=17
6569

6670
- name: CMake Build
6771
working-directory: test/cpp-tableau-loader

.github/workflows/testing-csharp.yml

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,43 +18,38 @@ jobs:
1818
matrix:
1919
include:
2020
- os: ubuntu-latest
21+
go-version: 1.21.x
2122
gen_script: bash gen.sh
2223
- os: windows-latest
24+
go-version: 1.21.x
2325
gen_script: cmd /c gen.bat
2426

27+
name: test (${{ matrix.os }})
2528
runs-on: ${{ matrix.os }}
2629
timeout-minutes: 10
2730

2831
steps:
2932
- name: Checkout Code
3033
uses: actions/checkout@v6
34+
with:
35+
submodules: recursive
3136

3237
- name: Install Go
3338
uses: actions/setup-go@v6
3439
with:
35-
go-version: 1.21.x
40+
go-version: ${{ matrix.go-version }}
3641
cache: true
3742

3843
- name: Install .NET SDK
3944
uses: actions/setup-dotnet@v4
4045
with:
4146
dotnet-version: "8.0.x"
4247

43-
- name: Install dependencies (Ubuntu)
44-
if: runner.os == 'Linux'
45-
run: sudo apt-get update && sudo apt-get install -y cmake ninja-build
46-
47-
- name: Install dependencies (Windows)
48-
if: runner.os == 'Windows'
49-
run: choco install cmake ninja -y
50-
51-
- name: Setup MSVC (Windows)
52-
if: runner.os == 'Windows'
53-
uses: ilammy/msvc-dev-cmd@v1
54-
55-
- name: Init submodules and build protobuf
56-
shell: bash
57-
run: bash init.sh
48+
- name: Install Protoc
49+
uses: arduino/setup-protoc@v1
50+
with:
51+
version: "3.19.3"
52+
repo-token: ${{ secrets.GITHUB_TOKEN }}
5853

5954
- name: Generate protoconf
6055
working-directory: test/csharp-tableau-loader

.github/workflows/testing-go.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,17 @@ jobs:
1616
test:
1717
strategy:
1818
matrix:
19-
go-version: [1.21.x]
20-
os: [ubuntu-latest, windows-latest]
19+
include:
20+
- os: ubuntu-latest
21+
go-version: 1.21.x
22+
gen_script: bash gen.sh
23+
- os: windows-latest
24+
go-version: 1.21.x
25+
gen_script: cmd /c gen.bat
2126

27+
name: test (${{ matrix.os }})
2228
runs-on: ${{ matrix.os }}
29+
timeout-minutes: 10
2330

2431
steps:
2532
- name: Checkout Code
@@ -34,17 +41,17 @@ jobs:
3441
cache: true
3542

3643
- name: Install Protoc
37-
uses: arduino/setup-protoc@v3
44+
uses: arduino/setup-protoc@v1
3845
with:
39-
version: "23.x"
46+
version: "3.19.3"
4047
repo-token: ${{ secrets.GITHUB_TOKEN }}
4148

4249
- name: Install protoc-gen-go
4350
run: go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.34.2
4451

4552
- name: Generate protoconf
46-
shell: bash
47-
run: PROTOC=protoc bash test/go-tableau-loader/gen.sh
53+
working-directory: test/go-tableau-loader
54+
run: ${{ matrix.gen_script }}
4855

4956
- name: Vet
5057
run: go vet ./...

init.bat

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,22 @@ cd /d "%repoRoot%"
1313

1414
git submodule update --init --recursive
1515

16-
REM google protobuf
17-
cd third_party\_submodules\protobuf
18-
git checkout v3.19.3
19-
git submodule update --init --recursive
20-
2116
REM Build and install the C++ Protocol Buffer runtime and the Protocol Buffer compiler (protoc)
2217
REM Refer: https://github.com/protocolbuffers/protobuf/blob/3.19.x/cmake/README.md#cmake-configuration
23-
cd cmake
18+
cd third_party\_submodules\protobuf\cmake
2419
REM use Debug version
2520
REM - protobuf_MSVC_STATIC_RUNTIME defaults to ON, which uses static CRT (/MTd for Debug).
2621
REM Our project's CMakeLists.txt also sets static CRT to match.
2722
REM - protobuf_WITH_ZLIB=OFF: disable ZLIB dependency to avoid ZLIB::ZLIB link requirement
2823
REM in protobuf's exported CMake targets, which simplifies cross-platform builds.
2924
REM - protobuf_BUILD_SHARED_LIBS=OFF: build static libraries explicitly.
30-
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_WITH_ZLIB=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF
25+
cmake -S . -B build -G Ninja ^
26+
-DCMAKE_BUILD_TYPE=Debug ^
27+
-DCMAKE_CXX_STANDARD=17 ^
28+
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 ^
29+
-Dprotobuf_BUILD_TESTS=OFF ^
30+
-Dprotobuf_WITH_ZLIB=OFF ^
31+
-Dprotobuf_BUILD_SHARED_LIBS=OFF
3132

3233
REM Compile the code
3334
cmake --build build --parallel

init.sh

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,21 @@ git submodule update --init --recursive
1111
# On Ubuntu/Debian, you can install them with:
1212
# sudo apt-get install autoconf automake libtool curl make g++ unzip
1313

14-
### reference: https://github.com/protocolbuffers/protobuf/tree/v3.19.3/src
15-
16-
# google protobuf
17-
cd third_party/_submodules/protobuf
18-
git checkout v3.19.3
19-
git submodule update --init --recursive
20-
2114
# Build and install the C++ Protocol Buffer runtime and the Protocol Buffer compiler (protoc)
2215
# Refer: https://github.com/protocolbuffers/protobuf/blob/3.19.x/cmake/README.md#cmake-configuration
23-
cd cmake
16+
cd third_party/_submodules/protobuf/cmake
2417
# use Debug version
2518
# - protobuf_MSVC_STATIC_RUNTIME defaults to ON, which uses static CRT (/MTd for Debug).
2619
# Our project's CMakeLists.txt also sets static CRT to match.
2720
# - protobuf_WITH_ZLIB=OFF: disable ZLIB dependency to avoid ZLIB::ZLIB link requirement
2821
# in protobuf's exported CMake targets, which simplifies cross-platform builds.
2922
# - protobuf_BUILD_SHARED_LIBS=OFF: build static libraries explicitly.
30-
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_WITH_ZLIB=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF
23+
cmake -S . -B build -G Ninja \
24+
-DCMAKE_BUILD_TYPE=Debug \
25+
-DCMAKE_CXX_STANDARD=17 \
26+
-Dprotobuf_BUILD_TESTS=OFF \
27+
-Dprotobuf_WITH_ZLIB=OFF \
28+
-Dprotobuf_BUILD_SHARED_LIBS=OFF
3129

3230
# Compile the code
3331
cmake --build build --parallel

test/cpp-tableau-loader/CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,24 @@ set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
5959
# link libraries
6060
target_link_libraries(${PROJECT_NAME} protobuf::libprotobuf)
6161
if(NOT MSVC)
62+
# When using clang with a GCC toolchain (e.g. gcc-toolset-13 on RHEL/CentOS),
63+
# clang selects GCC 13's C++ headers but the C compiler (GCC 8) may inject an
64+
# older libstdc++ search path into the link line. This causes undefined references
65+
# to symbols like std::__throw_bad_array_new_length() and std::filesystem::*.
66+
# Detect the GCC library directory used by the CXX compiler and link stdc++/stdc++fs
67+
# from there explicitly.
68+
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
69+
execute_process(
70+
COMMAND ${CMAKE_CXX_COMPILER} -print-libgcc-file-name
71+
OUTPUT_VARIABLE _LIBGCC_FILE
72+
OUTPUT_STRIP_TRAILING_WHITESPACE
73+
)
74+
if(_LIBGCC_FILE)
75+
get_filename_component(_GCC_LIB_DIR "${_LIBGCC_FILE}" DIRECTORY)
76+
message(STATUS "Detected GCC library directory for clang: ${_GCC_LIB_DIR}")
77+
# Prepend GCC toolchain lib dir so it is searched before the system GCC 8 path.
78+
target_link_options(${PROJECT_NAME} PRIVATE "-L${_GCC_LIB_DIR}")
79+
endif()
80+
endif()
6281
target_link_libraries(${PROJECT_NAME} pthread stdc++fs)
6382
endif()

0 commit comments

Comments
 (0)