From 98b0ef8ab5112bfb54f9093c5898ecab7a71ba68 Mon Sep 17 00:00:00 2001 From: Michael Graeb Date: Wed, 27 Nov 2024 21:53:12 +0000 Subject: [PATCH 1/4] Add CI check with _GLIBCXX_USE_CXX11_ABI=0 --- .github/workflows/ci.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 37879946f..823dc9b3e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ env: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true - + jobs: linux-compat-use-openssl: runs-on: ubuntu-22.04 # latest @@ -143,6 +143,18 @@ jobs: aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --compiler=${{ matrix.compiler }} --cmake-extra=-DBUILD_SHARED_LIBS=ON + linux-glibcxx-ancient-abi: + runs-on: ubuntu-22.04 # latest + strategy: + matrix: + compiler: [gcc-11] # oldest, latest + steps: + # We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages + - name: Build ${{ env.PACKAGE_NAME }} + run: | + aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh + ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --compiler=gcc-11 --cmake-extra=-DBUILD_SHARED_LIBS=ON --cmake-extra=-DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0 + linux-openssl-static: runs-on: ubuntu-22.04 # latest steps: From 8f93098eff724a65b22d0850c4417e0195bd5cbf Mon Sep 17 00:00:00 2001 From: Michael Graeb Date: Wed, 27 Nov 2024 22:03:59 +0000 Subject: [PATCH 2/4] Make all symbols visible when building with _GLIBCXX_USE_CXX11_ABI=0 I don't 100% understand why this fixes the issue, but the situation is esoteric enough that it doesn't seem worth spending any more days on this problem --- .github/workflows/ci.yml | 3 --- CMakeLists.txt | 14 +++++++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 823dc9b3e..11e4521b2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -145,9 +145,6 @@ jobs: linux-glibcxx-ancient-abi: runs-on: ubuntu-22.04 # latest - strategy: - matrix: - compiler: [gcc-11] # oldest, latest steps: # We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages - name: Build ${{ env.PACKAGE_NAME }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f062caa6..60d3d80a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -298,9 +298,17 @@ set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX) set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD ${CMAKE_CXX_STANDARD}) # Hide symbols by default -# Except for ancient GCC, because it leads to crashes in shared-lib builds -# see: https://github.com/awslabs/aws-crt-cpp/pull/675 -if(NOT (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0")) +# Except where it causes problems, and the situation is weird enough that it's not worth investigating further. +string(FIND "${CMAKE_CXX_FLAGS}" "-D_GLIBCXX_USE_CXX11_ABI=0" found_ancient_abi_flag) +if(found_ancient_abi_flag GREATER -1) + # We've seen people set _GLIBCXX_USE_CXX11_ABI=0 which forces GCC to use it's pre-C++11 string implementation. + # This leads to crashes on shared-lib builds. + message(STATUS "Cannot deal with hidden symbols when _GLIBCXX_USE_CXX11_ABI=0 is set, making everything visible") +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0") + # Ancient GCC leads to crashes in shared-lib builds + # see: https://github.com/awslabs/aws-crt-cpp/pull/675 + message(STATUS "Your compiler is too old to deal with hidden symbols, making everything visible") +else() set_target_properties(${PROJECT_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN ON) endif() From cabce8769f7f9c210e22e3f48672ef3de94d27ab Mon Sep 17 00:00:00 2001 From: Michael Graeb Date: Wed, 27 Nov 2024 22:44:37 +0000 Subject: [PATCH 3/4] trivial suggestions --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 11e4521b2..6b7a4bf16 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -144,9 +144,8 @@ jobs: ./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --compiler=${{ matrix.compiler }} --cmake-extra=-DBUILD_SHARED_LIBS=ON linux-glibcxx-ancient-abi: - runs-on: ubuntu-22.04 # latest + runs-on: ubuntu-24.04 # latest steps: - # We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages - name: Build ${{ env.PACKAGE_NAME }} run: | aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh From 4797a57ffceddbcd2a6fc45b4cecf6c1fc750988 Mon Sep 17 00:00:00 2001 From: Michael Graeb Date: Wed, 27 Nov 2024 23:56:38 +0000 Subject: [PATCH 4/4] Check every variant of CMAKE_CXX_FLAGS_ BTW check_cxx_source_compiles() doesn't use the _ flags --- CMakeLists.txt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 60d3d80a6..4127d0714 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -299,15 +299,17 @@ set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD ${CMAKE_CXX_STANDA # Hide symbols by default # Except where it causes problems, and the situation is weird enough that it's not worth investigating further. -string(FIND "${CMAKE_CXX_FLAGS}" "-D_GLIBCXX_USE_CXX11_ABI=0" found_ancient_abi_flag) +# +# We've seen people set _GLIBCXX_USE_CXX11_ABI=0 which forces GCC to use it's pre-C++11 string implementation, +# which leads to crashes on shared-lib builds. Search every variant of CXX_FLAGS to see if it's set. +string(FIND "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG} ${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${CMAKE_CXX_FLAGS_MINSIZEREL}" + "-D_GLIBCXX_USE_CXX11_ABI=0" found_ancient_abi_flag) if(found_ancient_abi_flag GREATER -1) - # We've seen people set _GLIBCXX_USE_CXX11_ABI=0 which forces GCC to use it's pre-C++11 string implementation. - # This leads to crashes on shared-lib builds. - message(STATUS "Cannot deal with hidden symbols when _GLIBCXX_USE_CXX11_ABI=0 is set, making everything visible") + message(WARNING "_GLIBCXX_USE_CXX11_ABI=0 is set. Making all symbols visible to prevent weird crashes") elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0") # Ancient GCC leads to crashes in shared-lib builds # see: https://github.com/awslabs/aws-crt-cpp/pull/675 - message(STATUS "Your compiler is too old to deal with hidden symbols, making everything visible") + message(WARNING "Ancient compiler (${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}). Making all symbols visible to prevent weird crashes") else() set_target_properties(${PROJECT_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN ON) endif()