From a8c98af06b0e71ab212411e84549b560695198f2 Mon Sep 17 00:00:00 2001 From: Sam Clark <3758302+goatgoose@users.noreply.github.com> Date: Fri, 23 Jun 2023 19:26:34 -0400 Subject: [PATCH 1/3] Add implicit gcc flag to all feature probes --- CMakeLists.txt | 6 +++++- bindings/rust/s2n-tls-sys/build.rs | 16 ++++++++++++---- s2n.mk | 2 +- tests/features/GLOBAL.flags | 1 + 4 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 tests/features/GLOBAL.flags diff --git a/CMakeLists.txt b/CMakeLists.txt index bc8e6554842..e9b7ecea190 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -313,6 +313,10 @@ endfunction() # Tries to compile a feature probe and initializes the corresponding flags function(feature_probe PROBE_NAME) + # Load the global probe flags + file(READ "${CMAKE_CURRENT_LIST_DIR}/tests/features/GLOBAL.flags" GLOBAL_FILE) + string(REPLACE "\n" "" GLOBAL_FLAGS "${GLOBAL_FILE}") + # Load the probe's flags file(READ "${CMAKE_CURRENT_LIST_DIR}/tests/features/${PROBE_NAME}.flags" PROBE_FILE) string(REPLACE "\n" "" PROBE_FLAGS "${PROBE_FILE}") @@ -324,7 +328,7 @@ function(feature_probe PROBE_NAME) SOURCES "${CMAKE_CURRENT_LIST_DIR}/tests/features/${PROBE_NAME}.c" LINK_LIBRARIES ${LINK_LIB} ${OS_LIBS} CMAKE_FLAGS ${ADDITIONAL_FLAGS} - COMPILE_DEFINITIONS -c ${PROBE_FLAGS} + COMPILE_DEFINITIONS -c ${GLOBAL_FLAGS} ${PROBE_FLAGS} ${ARGN} ) diff --git a/bindings/rust/s2n-tls-sys/build.rs b/bindings/rust/s2n-tls-sys/build.rs index f2e11ff8813..a3dc86e0876 100644 --- a/bindings/rust/s2n-tls-sys/build.rs +++ b/bindings/rust/s2n-tls-sys/build.rs @@ -52,11 +52,19 @@ impl<'a> FeatureDetector<'a> { let file = base.with_extension("c"); assert!(file.exists(), "missing feature file: {:?}", file.display()); - let flags = base.with_extension("flags"); - assert!(file.exists(), "missing flags file: {:?}", flags.display()); + let global_flags = std::path::Path::new("lib/tests/features/GLOBAL.flags"); + assert!(global_flags.exists(), "missing flags file: {:?}", global_flags.display()); - let flags = std::fs::read_to_string(flags).unwrap(); - for flag in flags.trim().split(' ').filter(|f| !f.is_empty()) { + let global_flags = std::fs::read_to_string(global_flags).unwrap(); + for flag in global_flags.trim().split(' ').filter(|f| !f.is_empty()) { + build.arg(flag); + } + + let probe_flags = base.with_extension("flags"); + assert!(probe_flags.exists(), "missing flags file: {:?}", probe_flags.display()); + + let probe_flags = std::fs::read_to_string(probe_flags).unwrap(); + for flag in probe_flags.trim().split(' ').filter(|f| !f.is_empty()) { build.arg(flag); } diff --git a/s2n.mk b/s2n.mk index 98cd92e2eb8..b384e795e75 100644 --- a/s2n.mk +++ b/s2n.mk @@ -181,7 +181,7 @@ bindir ?= $(exec_prefix)/bin libdir ?= $(exec_prefix)/lib64 includedir ?= $(exec_prefix)/include -feature_probe = $(shell $(CC) $(CFLAGS) $(shell cat $(S2N_ROOT)/tests/features/$(1).flags) -c -o tmp.o $(S2N_ROOT)/tests/features/$(1).c > /dev/null 2>&1 && echo "-D$(1)"; rm tmp.o > /dev/null 2>&1) +feature_probe = $(shell $(CC) $(CFLAGS) $(shell cat $(S2N_ROOT)/tests/features/GLOBAL.flags) $(shell cat $(S2N_ROOT)/tests/features/$(1).flags) -c -o tmp.o $(S2N_ROOT)/tests/features/$(1).c > /dev/null 2>&1 && echo "-D$(1)"; rm tmp.o > /dev/null 2>&1) FEATURES := $(notdir $(patsubst %.c,%,$(wildcard $(S2N_ROOT)/tests/features/*.c))) SUPPORTED_FEATURES := $(foreach feature,$(FEATURES),$(call feature_probe,$(feature))) diff --git a/tests/features/GLOBAL.flags b/tests/features/GLOBAL.flags new file mode 100644 index 00000000000..be01a243fd9 --- /dev/null +++ b/tests/features/GLOBAL.flags @@ -0,0 +1 @@ +-Werror=implicit-function-declaration From 89a773d7f46e02e699356df10a0f6c014057ca93 Mon Sep 17 00:00:00 2001 From: Sam Clark <3758302+goatgoose@users.noreply.github.com> Date: Tue, 27 Jun 2023 10:22:29 -0400 Subject: [PATCH 2/3] OpenSSL 1.0.2 GH action --- .github/workflows/ci_rust.yml | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/.github/workflows/ci_rust.yml b/.github/workflows/ci_rust.yml index 5b337c1258a..7c69774d8d5 100644 --- a/.github/workflows/ci_rust.yml +++ b/.github/workflows/ci_rust.yml @@ -59,6 +59,54 @@ jobs: ./generate.sh ldd target/debug/integration | grep libs2n.so + generate-openssl-102: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions-rs/toolchain@v1 + id: toolchain + with: + toolchain: stable + override: true + + - uses: camshaft/rust-cache@v1 + + - name: Cache OpenSSL 1.0.2 + id: cache-openssl + uses: actions/cache@v3 + with: + path: ~/openssl-102/install + key: ${{ runner.os }}-openssl-102 + + - if: ${{ steps.cache-openssl.outputs.cache-hit != 'true' }} + name: Install OpenSSL 1.0.2 + run: | + mkdir ~/openssl-102 + pushd ~/openssl-102 + + mkdir install + install_dir="$(pwd)"/install + + wget https://www.openssl.org/source/old/1.0.2/openssl-1.0.2u.tar.gz + tar -xzvf openssl-1.0.2u.tar.gz + + pushd openssl-1.0.2u + mkdir install + ./config --prefix="${install_dir}" --openssldir="${install_dir}"/openssl + make + make install + popd + + popd + + - name: Generate + run: OPENSSL_DIR=~/openssl-102/install ${{env.ROOT_PATH}}/generate.sh + + - name: Tests + working-directory: ${{env.ROOT_PATH}} + run: cargo test --all-features + rustfmt: runs-on: ubuntu-latest steps: From 244448e14c0a829846904a3f2010230ee79af5c3 Mon Sep 17 00:00:00 2001 From: Sam Clark <3758302+goatgoose@users.noreply.github.com> Date: Tue, 27 Jun 2023 11:01:55 -0400 Subject: [PATCH 3/3] rustfmt fix --- .github/workflows/ci_rust.yml | 1 - bindings/rust/s2n-tls-sys/build.rs | 22 +++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci_rust.yml b/.github/workflows/ci_rust.yml index 7c69774d8d5..09300b8a3c2 100644 --- a/.github/workflows/ci_rust.yml +++ b/.github/workflows/ci_rust.yml @@ -92,7 +92,6 @@ jobs: tar -xzvf openssl-1.0.2u.tar.gz pushd openssl-1.0.2u - mkdir install ./config --prefix="${install_dir}" --openssldir="${install_dir}"/openssl make make install diff --git a/bindings/rust/s2n-tls-sys/build.rs b/bindings/rust/s2n-tls-sys/build.rs index a3dc86e0876..03a9698cc8b 100644 --- a/bindings/rust/s2n-tls-sys/build.rs +++ b/bindings/rust/s2n-tls-sys/build.rs @@ -47,21 +47,29 @@ impl<'a> FeatureDetector<'a> { pub fn supports(&self, name: &str) -> bool { let mut build = self.builder.get_compiler().to_command(); - let base = std::path::Path::new("lib/tests/features").join(name); - - let file = base.with_extension("c"); - assert!(file.exists(), "missing feature file: {:?}", file.display()); - let global_flags = std::path::Path::new("lib/tests/features/GLOBAL.flags"); - assert!(global_flags.exists(), "missing flags file: {:?}", global_flags.display()); + assert!( + global_flags.exists(), + "missing flags file: {:?}", + global_flags.display() + ); let global_flags = std::fs::read_to_string(global_flags).unwrap(); for flag in global_flags.trim().split(' ').filter(|f| !f.is_empty()) { build.arg(flag); } + let base = std::path::Path::new("lib/tests/features").join(name); + + let file = base.with_extension("c"); + assert!(file.exists(), "missing feature file: {:?}", file.display()); + let probe_flags = base.with_extension("flags"); - assert!(probe_flags.exists(), "missing flags file: {:?}", probe_flags.display()); + assert!( + probe_flags.exists(), + "missing flags file: {:?}", + probe_flags.display() + ); let probe_flags = std::fs::read_to_string(probe_flags).unwrap(); for flag in probe_flags.trim().split(' ').filter(|f| !f.is_empty()) {