Skip to content

Commit 2253531

Browse files
authored
Fix for s2n_prelude.h Changes (#299)
1 parent 93ac601 commit 2253531

File tree

13 files changed

+55
-16
lines changed

13 files changed

+55
-16
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Detect changes to s2n_prelude.h to update our `Package.swift` and stay in sync with it.
2+
# See: https://github.com/awslabs/aws-crt-swift/pull/299 for updating the Package.swift.
3+
4+
name: s2n_prelude.h Change Detector
5+
6+
on: [push]
7+
8+
jobs:
9+
check-for-changes:
10+
11+
runs-on: ubuntu-24.04 # latest
12+
13+
steps:
14+
- name: Checkout Sources
15+
uses: actions/checkout@v4
16+
with:
17+
submodules: true
18+
19+
- name: Check s2n_prelude.h
20+
run: |
21+
TMPFILE=$(mktemp)
22+
echo "116f1525acbc94c91b0ee2ea2af9fdef aws-common-runtime/s2n/utils/s2n_prelude.h" > $TMPFILE
23+
md5sum --check $TMPFILE
24+
25+
# No further steps if successful
26+
27+
- name: Echo fail
28+
if: failure()
29+
run: |
30+
echo "The aws-crt-swift has a hack to manually define macros which are defined in s2n_prelude.h in Package.Swift.
31+
This check will fail whenever s2n_prelude.h is updated by the S2N team. You should make sure that Package.Swift is updated accordingly
32+
with the s2n_prelude.h changes and then run `md5sum aws-common-runtime/s2n/utils/s2n_prelude.h` and update the value above."

Package.swift

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,17 @@ packageTargets.append(.target(
100100
publicHeadersPath: "api",
101101
cSettings: [
102102
.headerSearchPath("./"),
103-
.define("POSIX_C_SOURCE=200809L"),
104-
.define("S2N_NO_PQ")
103+
.define("S2N_NO_PQ"),
104+
// This is a hack to get around the fact that S2N uses the compiler option `-include`
105+
// to include `s2n_prelude.h` in all .c files. Since SwiftPM doesn't support compiler flags,
106+
// we manually define the macros from `s2n_prelude.h`. When SwiftPM supports compiler flags
107+
// or building packages using CMake, this hack should be removed.
108+
// We are not defining `S2N_API` because we don't need to expose any symbols from S2N in crt-swift.
109+
.define("_S2N_PRELUDE_INCLUDED"),
110+
.define("S2N_BUILD_RELEASE"),
111+
.define("_FORTIFY_SOURCE", to: "2"),
112+
.define("POSIX_C_SOURCE", to: "200809L"),
113+
105114
]
106115
))
107116
#endif
@@ -146,9 +155,6 @@ var awsCChecksumsExcludes = [
146155
"cmake",
147156
"tests"]
148157

149-
// swift never uses Microsoft Visual C++ compiler
150-
awsCChecksumsExcludes.append("source/intel/visualc")
151-
152158
// Hardware accelerated checksums are disabled because SwiftPM doesn't like the necessary compiler flags.
153159
// We can add it once SwiftPM has the necessary support for CPU flags or builds C libraries
154160
// using CMake.

0 commit comments

Comments
 (0)