Skip to content

Modern build fixes#3822

Closed
jmklix wants to merge 11 commits intoaws:mainfrom
jmklix:modern-build-fixes
Closed

Modern build fixes#3822
jmklix wants to merge 11 commits intoaws:mainfrom
jmklix:modern-build-fixes

Conversation

@jmklix
Copy link
Copy Markdown
Member

@jmklix jmklix commented May 7, 2026

Issue #, if available:

#1888

Description of changes:

Addresses gaps in the modern (non-legacy) build path (-DLEGACY_BUILD=OFF) identified through a comprehensive multi-agent architecture review:

Build correctness:

  • Remove global add_compile_definitions() leak in aws_sdk_platform.cmake that polluted FetchContent consumers' targets. CRT HTTP defines now applied per-target only.
  • Fix zlib linkage: disable ENABLED_ZLIB_REQUEST_COMPRESSION define since source directly calls zlib APIs and CRT compression adapter is not yet implemented.
    ENABLED_REQUEST_COMPRESSION still set for future CRT-based implementation.
  • Restrict hidden symbol visibility to Windows only (Unix SDK headers lack visibility("default") annotations on AWS_CORE_API).
  • Add early FATAL_ERROR if AWS_SDK_BUILD_ONLY is empty — fails fast before CRT download instead of after.
  • Add C++14 minimum validation guard.
  • Add CMake policy CMP0091 guard for MSVC_RUNTIME_LIBRARY compatibility on CMake 3.14.

Supply chain security:

  • Pin GoogleTest to commit SHA (f8d7d77c) instead of mutable tag v1.14.0.
  • Replace zlib FetchContent with CRT compression path (eliminates third-party dependency).

CI & quality:

  • Rewrite modern-build.yml with inline 12-config matrix (3 OS × 2 build types × 2 shared/static) replacing broken reference to non-existent build-matrix.json.
  • Add source-package-offline CI job validating CPack archives build without network.
  • Add symbol_check.cmake — post-build CTest verification that no gtest/tinyxml2/cjson symbols leak from installed artifacts.

Documentation:

  • Create docs/Migration_Guide.md with before/after examples, option mapping table, offline build instructions, and deprecation timeline.
  • Add modern build parameters section to docs/CMake_Parameters.md.
  • Add cmake/README.md documenting module architecture and consumption patterns.

Check all that applies:

  • Did a review by yourself.
  • Added proper tests to cover this PR. (Symbol leakage verification via CTest; CI workflow validates configure/build/install/consume cycle.)
  • Checked if this PR is a breaking (APIs have been changed) change. (No breaking changes — legacy path LEGACY_BUILD=ON is untouched and remains the default.)
  • Checked if this PR will not introduce cross-platform inconsistent behavior.
  • Checked if this PR would require a ReadMe/Wiki update. (Migration Guide and CMake Parameters docs included in this PR.)

Check which platforms you have built SDK on to verify the correctness of this PR.

  • Linux
  • Windows
  • Android
  • MacOS
  • IOS
  • Other Platforms

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

jmklix added 11 commits May 5, 2026 14:33
Replace cJSON, tinyXML2, and system zlib with CRT-based alternatives
in the modern build path (LEGACY_BUILD=OFF):

- 2a: Replace cJSON with aws-c-common JSON parser (aws/common/json.h)
  - New: source/utils/json/JsonSerializer_crt.cpp
  - New: source/utils/Document_crt.cpp
  - Headers conditionally use aws_json_value* via NON_LEGACY_BUILD

- 2b: Replace tinyXML2 with aws-c-common XML parser (SAX-to-DOM bridge)
  - New: source/utils/xml/XmlSerializer_crt.cpp
  - Header conditionally uses shared_ptr-based DOM tree

- 2c: Replace system zlib with FetchContent-bundled zlib
  - Compression always available without system install
  - AWS_SDK_USE_INSTALLED_ZLIB=ON for system zlib opt-in

- 2d: Replace embedded gtest with FetchContent googletest
  - New: cmake/fetch_test_dependencies.cmake
  - Gated behind AWS_SDK_ENABLE_TESTING
  - AWS_SDK_USE_INSTALLED_GTEST=ON for system gtest opt-in

The legacy build path remains unchanged. All changes are gated behind
the NON_LEGACY_BUILD compile definition.
Add remaining Phase 1 files that were not previously committed:

- cmake/aws_sdk_compiler.cmake: Per-target compiler flags
- cmake/aws_sdk_options.cmake: Centralized options with AWS_SDK_ prefix
- cmake/fetch_dependencies.cmake: FetchContent-based CRT dependency
- src/aws-cpp-sdk-core/CMakeLists.txt: Dispatch guard to route to
  CMakeLists.modern.txt when LEGACY_BUILD=OFF
Implement Phase 3 of the build modernization:

- Create cmake/aws_sdk_service_clients.cmake with functions to discover
  and build generated service clients filtered by AWS_SDK_BUILD_ONLY
- Make AWS_SDK_BUILD_ONLY required with a clear FATAL_ERROR message
- Wire up high-level SDKs (transfer, s3-encryption, identity-management,
  queues, text-to-speech, access-management) with dependency resolution
  from sdksCommon.cmake
- Fix symbol visibility: remove global hidden visibility preset that
  conflicts with the SDK's export mechanism on non-Windows platforms
- Fix DLL export macro to only apply on Windows (non-Windows uses the
  template instantiation guards in generated endpoint provider sources)

Tested with -DAWS_SDK_BUILD_ONLY=s3 - both core and S3 build and link
successfully as shared libraries.

cr: https://code.amazon.com/reviews/CR-272324241
Gate all test logic behind AWS_SDK_ENABLE_TESTING option. Port
testing-resources and aws-cpp-sdk-core-tests to the modern build path
using GTest::gtest from FetchContent instead of embedded gtest source.

- Add CMakeLists.modern.txt for tests/testing-resources
- Add CMakeLists.modern.txt for tests/aws-cpp-sdk-core-tests
- Add dispatch guards to existing CMakeLists.txt files
- Wire up test subdirectories in root CMakeLists.txt modern path
- Fix InterceptorTest.cpp Optional<String> comparison with gtest
- Verify no gtest symbols leak into SDK shared libraries
Add cmake/aws_sdk_packaging.cmake which configures CPack to generate
TGZ and ZIP source tarballs via the package_source target. Include it
at the bottom of the modern (LEGACY_BUILD=OFF) build path.

Users can now run:
  cmake --build <build-dir> --target package_source

to produce aws-sdk-cpp-<version>-Source.{tar.gz,zip} for GitHub Releases.
Add tools/CI/build-matrix.json defining platform configurations (AL2,
Ubuntu, macOS, Windows, Android) and a GitHub Actions workflow that
reads the matrix and fans out parallel builds with LEGACY_BUILD=OFF.

Triggered on changes to CMakeLists.txt, cmake/**, and core sources.
The modern build path is now the default. Users who need the legacy
path can still opt in with -DLEGACY_BUILD=ON for one release cycle.
The legacy path will be removed entirely in 1.12.0.
- Change LEGACY_BUILD default to ON for safe migration
- Add install/export rules for service clients (find_package support)
- Fix cross-compilation: use target platform vars instead of CMAKE_HOST_*
- Pin CRT to commit SHA (bd19f64) for supply chain security
- Add find_package(AWSSDK) backward-compatibility forwarding shim
- Update README with Modern Build section and FetchContent example
- Remove global add_compile_definitions leak in aws_sdk_platform.cmake;
  CRT HTTP defines now applied per-target only
- Add per-target hidden symbol visibility (CXX_VISIBILITY_PRESET hidden)
- Pin GTest to commit SHA (f8d7d77c) instead of mutable tag
- Replace zlib FetchContent with CRT compression (aws-c-compression)
- Add C++14 minimum validation guard in aws_sdk_options.cmake
- Add CMP0091 policy guard for MSVC_RUNTIME_LIBRARY compatibility
- Rewrite CI workflow with inline 12-config matrix and offline build job
- Create docs/Migration_Guide.md with deprecation timeline and
  before/after examples for legacy-to-modern migration
…tecture docs

- Add early FATAL_ERROR if AWS_SDK_BUILD_ONLY is empty, before CRT
  fetch (fail fast instead of waiting for download)
- Add cmake/modern/symbol_check.cmake: post-build verification that
  no gtest/tinyxml2/cjson symbols leak from installed artifacts
  (design doc requirement aws#10)
- Wire symbol check into modern build path for aws-cpp-sdk-core
- Add cmake/README.md documenting modern build architecture, module
  responsibilities, and consumption patterns
- Disable ENABLED_ZLIB_REQUEST_COMPRESSION define (source calls zlib
  directly; CRT compression adapter not yet implemented)
- Restrict hidden visibility to Windows only (Unix SDK headers lack
  visibility("default") annotations on AWS_CORE_API)
- Fix symbol_check.cmake to use add_test instead of POST_BUILD
  (target created in subdirectory, not accessible from root)
- Add enable_testing() before symbol check registration
@jmklix jmklix requested a review from sbiscigl May 7, 2026 18:49
@jmklix jmklix closed this May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant