Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add implicit gcc flag to all feature probes #4074

Merged
merged 4 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/ci_rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,53 @@ 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
./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:
Expand Down
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand All @@ -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}
)

Expand Down
24 changes: 20 additions & 4 deletions bindings/rust/s2n-tls-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,32 @@ impl<'a> FeatureDetector<'a> {
pub fn supports(&self, name: &str) -> bool {
let mut build = self.builder.get_compiler().to_command();

let global_flags = std::path::Path::new("lib/tests/features/GLOBAL.flags");
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 flags = base.with_extension("flags");
assert!(file.exists(), "missing flags file: {:?}", flags.display());
let probe_flags = base.with_extension("flags");
assert!(
probe_flags.exists(),
"missing flags file: {:?}",
probe_flags.display()
);

let flags = std::fs::read_to_string(flags).unwrap();
for flag in flags.trim().split(' ').filter(|f| !f.is_empty()) {
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);
}

Expand Down
2 changes: 1 addition & 1 deletion s2n.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
1 change: 1 addition & 0 deletions tests/features/GLOBAL.flags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-Werror=implicit-function-declaration