1212 ARTIFACT_PIKA_NAME : artifact-pika
1313
1414jobs :
15+
1516 build_on_ubuntu :
1617 # The CMake configure and build commands are platform-agnostic and should work equally well on Windows or Mac.
1718 # You can convert this to a matrix build if you need cross-platform coverage.
@@ -41,12 +42,49 @@ jobs:
4142 - name : Install Deps
4243 run : |
4344 sudo apt-get update
44- sudo apt-get install -y autoconf libprotobuf-dev protobuf-compiler clang-tidy
45+ sudo apt-get install -y autoconf libprotobuf-dev protobuf-compiler clang-tidy gcc-11 g++-11 zlib1g-dev
46+
47+ - name : Patch glibc headers for GCC compatibility
48+ run : |
49+ # Workaround for __has_attribute compatibility issue between newer glibc and GCC
50+ # The issue is that __glibc_has_attribute uses parenthesized arguments like __glibc_has_attribute(__const__)
51+ # which is incompatible with GCC's __has_attribute implementation in GCC 11+
52+ #
53+ # Solution: Redefine __glibc_has_attribute to always return 0
54+ # This is done by replacing the macro definition itself
55+
56+ CDEFS_FILE=""
57+ if [ -f /usr/include/x86_64-linux-gnu/sys/cdefs.h ]; then
58+ CDEFS_FILE="/usr/include/x86_64-linux-gnu/sys/cdefs.h"
59+ elif [ -f /usr/include/sys/cdefs.h ]; then
60+ CDEFS_FILE="/usr/include/sys/cdefs.h"
61+ fi
62+
63+ if [ -n "$CDEFS_FILE" ]; then
64+ echo "Patching $CDEFS_FILE"
65+ echo "=== Before patching (lines with __glibc_has_attribute) ==="
66+ grep -n "__glibc_has_attribute" "$CDEFS_FILE" || echo "No matches found"
67+ echo "=========================================================="
68+
69+ sudo cp "$CDEFS_FILE" /tmp/cdefs.h.backup
70+
71+ # Replace the macro definition that uses __has_attribute with one that always returns 0
72+ # Original: # define __glibc_has_attribute(attr) __has_attribute (attr)
73+ # Changed: # define __glibc_has_attribute(attr) 0
74+ # Use extended regex (-E) for better pattern matching
75+ sudo sed -i -E 's/#[ \t]*define[ \t]+__glibc_has_attribute\(attr\)[ \t]+__has_attribute[ \t]*\(attr\)/#define __glibc_has_attribute(attr) 0/g' "$CDEFS_FILE"
76+
77+ echo "=== After patching (lines with __glibc_has_attribute) ==="
78+ grep -n "__glibc_has_attribute" "$CDEFS_FILE" || echo "No matches found"
79+ echo "========================================================="
80+
81+ echo "=== Verifying line 331 area ==="
82+ sed -n '325,340p' "$CDEFS_FILE"
83+ echo "==============================="
84+ fi
4585
4686 - name : Configure CMake
47- # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
48- # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
49- run : cmake -B build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DUSE_PIKA_TOOLS=ON -DCMAKE_CXX_FLAGS_DEBUG=-fsanitize=address -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
87+ run : cmake -B build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DUSE_PIKA_TOOLS=ON -DCMAKE_CXX_FLAGS_DEBUG=-fsanitize=address -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11
5088
5189 - name : Build
5290 # Build your program with the given configuration
@@ -166,7 +204,7 @@ jobs:
166204 - name : Install deps
167205 run : |
168206 dnf update -y
169- dnf install -y bash cmake wget git autoconf gcc perl-Digest-SHA tcl which tar g++ tar epel-release gcc-c++ libstdc++-devel gcc-toolset-13 binutils
207+ dnf install -y bash cmake wget git autoconf gcc perl-Digest-SHA tcl which tar g++ tar epel-release gcc-c++ libstdc++-devel gcc-toolset-12 binutils openssl openssl-devel zlib-devel
170208 dnf clean all
171209 rm -rf /var/cache/dnf
172210
@@ -180,9 +218,43 @@ jobs:
180218 with :
181219 fetch-depth : 1
182220
221+ - name : Patch glibc headers for GCC compatibility
222+ run : |
223+ # Workaround for __has_attribute compatibility issue between newer glibc and GCC
224+ # The issue is that __glibc_has_attribute uses parenthesized arguments like __glibc_has_attribute(__const__)
225+ # which is incompatible with GCC's __has_attribute implementation in GCC 11+
226+ #
227+ # Solution: Redefine __glibc_has_attribute to always return 0
228+ # This is done by replacing the macro definition itself
229+
230+ CDEFS_FILE="/usr/include/sys/cdefs.h"
231+
232+ if [ -f "$CDEFS_FILE" ]; then
233+ echo "Patching $CDEFS_FILE"
234+ echo "=== Before patching (lines with __glibc_has_attribute) ==="
235+ grep -n "__glibc_has_attribute" "$CDEFS_FILE" || echo "No matches found"
236+ echo "=========================================================="
237+
238+ cp "$CDEFS_FILE" /tmp/cdefs.h.backup
239+
240+ # Replace the macro definition that uses __has_attribute with one that always returns 0
241+ # Original: # define __glibc_has_attribute(attr) __has_attribute (attr)
242+ # Changed: # define __glibc_has_attribute(attr) 0
243+ # Use extended regex (-E) for better pattern matching
244+ sed -i -E 's/#[ \t]*define[ \t]+__glibc_has_attribute\(attr\)[ \t]+__has_attribute[ \t]*\(attr\)/#define __glibc_has_attribute(attr) 0/g' "$CDEFS_FILE"
245+
246+ echo "=== After patching (lines with __glibc_has_attribute) ==="
247+ grep -n "__glibc_has_attribute" "$CDEFS_FILE" || echo "No matches found"
248+ echo "========================================================="
249+
250+ echo "=== Verifying line 331 area ==="
251+ sed -n '325,340p' "$CDEFS_FILE"
252+ echo "==============================="
253+ fi
254+
183255 - name : Configure CMake
184256 run : |
185- source /opt/rh/gcc-toolset-13 /enable
257+ source /opt/rh/gcc-toolset-12 /enable
186258 cmake -B build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DUSE_PIKA_TOOLS=ON -DCMAKE_CXX_FLAGS_DEBUG=-fsanitize=address .
187259
188260 - uses : actions/cache@v3
@@ -197,7 +269,7 @@ jobs:
197269
198270 - name : Build
199271 run : |
200- source /opt/rh/gcc-toolset-13 /enable
272+ source /opt/rh/gcc-toolset-12 /enable
201273 cmake --build build --config ${{ env.BUILD_TYPE }}
202274
203275 - name : Cleanup
@@ -292,13 +364,14 @@ jobs:
292364 - name : Install Deps
293365 run : |
294366 brew list --versions cmake && brew uninstall --ignore-dependencies --force cmake || true
295- brew install gcc@13 automake cmake make binutils
367+ brew install gcc@11 automake cmake make binutils
296368
297369 - name : Configure CMake
370+ # Use GCC 11 to avoid potential __has_attribute compatibility issues with GCC 13
298371 run : |
299- GCC_PREFIX=$(brew --prefix gcc@13 )
300- export CC=$GCC_PREFIX/bin/gcc-13
301- cmake -B build -DCMAKE_C_COMPILER=$GCC_PREFIX/bin/gcc-13 -DUSE_PIKA_TOOLS=ON -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCMAKE_CXX_FLAGS_DEBUG=-fsanitize=address -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
372+ GCC_PREFIX=$(brew --prefix gcc@11 )
373+ export CC=$GCC_PREFIX/bin/gcc-11
374+ cmake -B build -DCMAKE_C_COMPILER=$GCC_PREFIX/bin/gcc-11 -DUSE_PIKA_TOOLS=ON -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCMAKE_CXX_FLAGS_DEBUG=-fsanitize=address -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
302375
303376 - name : Build
304377 run : |
0 commit comments