Skip to content

Commit 8f500e5

Browse files
committed
Build: Add separate LDFLAGS
Signed-off-by: willieyz <willie.zhao@chelpis.com>
1 parent 9ff878f commit 8f500e5

10 files changed

Lines changed: 74 additions & 6 deletions

File tree

.github/actions/bench/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ inputs:
1717
archflags:
1818
description: ARCHFLAGS to pass to compilation
1919
default: ""
20+
ldflags:
21+
description: LDFLAGS to pass to compilation
22+
default: ""
2023
opt:
2124
description: opt flag to set for tests script
2225
default: "true"
@@ -75,11 +78,13 @@ runs:
7578
run: |
7679
./scripts/tests bench -c ${{ inputs.perf }} --cross-prefix="${{ inputs.cross_prefix }}" \
7780
--cflags="${{ inputs.cflags }} ${{ inputs.archflags }}" \
81+
--ldflags="${{ inputs.ldflags }}" \
7882
--opt=$([[ ${{ inputs.opt }} == "false" ]] && echo "no_opt" || echo "opt") \
7983
-v --output=output.json ${{ inputs.bench_extra_args }}
8084
8185
./scripts/tests bench --components -c ${{ inputs.perf }} --cross-prefix="${{ inputs.cross_prefix }}" \
8286
--cflags="${{ inputs.cflags }} ${{ inputs.archflags }}" \
87+
--ldflags="${{ inputs.ldflags }}" \
8388
--opt=$([[ ${{ inputs.opt }} == "false" ]] && echo "no_opt" || echo "opt") \
8489
-v ${{ inputs.bench_extra_args }}
8590
- name: Check namespace

.github/actions/config-variations/action.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ runs:
2424
gh_token: ${{ inputs.gh_token }}
2525
compile_mode: native
2626
cflags: "-DMLK_CONFIG_KEYGEN_PCT -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
27+
ldflags: "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
2728
func: true
2829
kat: true
2930
acvp: true
@@ -52,6 +53,7 @@ runs:
5253
gh_token: ${{ inputs.gh_token }}
5354
compile_mode: native
5455
cflags: "-std=c11 -D_GNU_SOURCE -DMLK_CONFIG_FILE=\\\\\\\"../../test/custom_zeroize_config.h\\\\\\\" -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
56+
ldflags: "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
5557
func: true
5658
kat: true
5759
acvp: true
@@ -64,6 +66,7 @@ runs:
6466
gh_token: ${{ inputs.gh_token }}
6567
compile_mode: native
6668
cflags: "-std=c11 -D_GNU_SOURCE -DMLK_CONFIG_FILE=\\\\\\\"../../test/custom_native_capability_config_1.h\\\\\\\" -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
69+
ldflags: "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
6770
func: true
6871
kat: true
6972
acvp: true
@@ -76,6 +79,7 @@ runs:
7679
gh_token: ${{ inputs.gh_token }}
7780
compile_mode: native
7881
cflags: "-std=c11 -D_GNU_SOURCE -DMLK_CONFIG_FILE=\\\\\\\"../../test/custom_native_capability_config_0.h\\\\\\\" -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
82+
ldflags: "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
7983
func: true
8084
kat: true
8185
acvp: true
@@ -88,6 +92,7 @@ runs:
8892
gh_token: ${{ inputs.gh_token }}
8993
compile_mode: native
9094
cflags: "-std=c11 -march=armv8.4-a+sha3 -D_GNU_SOURCE -DMLK_CONFIG_FILE=\\\\\\\"../../test/custom_native_capability_config_ID_AA64PFR1_EL1.h\\\\\\\" -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
95+
ldflags: "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
9196
func: true
9297
kat: true
9398
acvp: true
@@ -100,6 +105,7 @@ runs:
100105
gh_token: ${{ inputs.gh_token }}
101106
compile_mode: native
102107
cflags: "-std=c11 -mavx2 -mbmi2 -mpopcnt -D_GNU_SOURCE -DMLK_CONFIG_FILE=\\\\\\\"../../test/custom_native_capability_config_CPUID_AVX2.h\\\\\\\" -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
108+
ldflags: "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
103109
func: true
104110
kat: true
105111
acvp: true
@@ -112,6 +118,7 @@ runs:
112118
gh_token: ${{ inputs.gh_token }}
113119
compile_mode: native
114120
cflags: "-std=c11 -D_GNU_SOURCE -DMLK_CONFIG_FILE=\\\\\\\"../../test/no_asm_config.h\\\\\\\" -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
121+
ldflags: "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
115122
func: true
116123
kat: true
117124
acvp: true
@@ -124,6 +131,7 @@ runs:
124131
gh_token: ${{ inputs.gh_token }}
125132
compile_mode: native
126133
cflags: "-std=c11 -D_GNU_SOURCE -DMLK_CONFIG_FILE=\\\\\\\"../../test/custom_randombytes_config.h\\\\\\\" -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
134+
ldflags: "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
127135
func: true
128136
kat: true
129137
acvp: true
@@ -136,6 +144,7 @@ runs:
136144
gh_token: ${{ inputs.gh_token }}
137145
compile_mode: native
138146
cflags: "-std=c11 -D_GNU_SOURCE -DMLK_CONFIG_FILE=\\\\\\\"../../test/custom_memcpy_config.h\\\\\\\" -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
147+
ldflags: "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
139148
func: true
140149
kat: true
141150
acvp: true
@@ -148,6 +157,7 @@ runs:
148157
gh_token: ${{ inputs.gh_token }}
149158
compile_mode: native
150159
cflags: "-std=c11 -D_GNU_SOURCE -DMLK_CONFIG_FILE=\\\\\\\"../../test/custom_memset_config.h\\\\\\\" -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
160+
ldflags: "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
151161
func: true
152162
kat: true
153163
acvp: true
@@ -160,6 +170,7 @@ runs:
160170
gh_token: ${{ inputs.gh_token }}
161171
compile_mode: native
162172
cflags: "-std=c11 -D_GNU_SOURCE -DMLK_CONFIG_FILE=\\\\\\\"../../test/custom_stdlib_config.h\\\\\\\" -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
173+
ldflags: "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
163174
func: true
164175
kat: true
165176
acvp: true
@@ -172,6 +183,7 @@ runs:
172183
gh_token: ${{ inputs.gh_token }}
173184
compile_mode: native
174185
cflags: "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -DMLKEM_GEN_MATRIX_NBLOCKS=1"
186+
ldflags: "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
175187
func: true
176188
kat: true
177189
acvp: true
@@ -184,6 +196,7 @@ runs:
184196
gh_token: ${{ inputs.gh_token }}
185197
compile_mode: native
186198
cflags: "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -DMLKEM_GEN_MATRIX_NBLOCKS=2"
199+
ldflags: "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
187200
func: true
188201
kat: true
189202
acvp: true
@@ -196,6 +209,7 @@ runs:
196209
gh_token: ${{ inputs.gh_token }}
197210
compile_mode: native
198211
cflags: "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -DMLKEM_GEN_MATRIX_NBLOCKS=4"
212+
ldflags: "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
199213
func: true
200214
kat: true
201215
acvp: true

.github/actions/functest/action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ inputs:
2222
cflags:
2323
description: CFLAGS to pass to compilation
2424
default: ""
25+
ldflags:
26+
description: LDFLAGS to pass to linking
27+
default: ""
2528
cross_prefix:
2629
description: Binary prefix for cross compilation
2730
default: ""
@@ -99,7 +102,7 @@ runs:
99102
shell: ${{ env.SHELL }}
100103
run: |
101104
make clean
102-
./scripts/tests all ${{ inputs.check_namespace == 'true' && '--check-namespace' || ''}} --exec-wrapper="${{ inputs.exec_wrapper }}" --cross-prefix="${{ inputs.cross_prefix }}" --cflags="${{ inputs.cflags }}" --opt=${{ inputs.opt }} --${{ env.FUNC }} --${{ env.KAT }} --${{ env.ACVP }} --${{ env.EXAMPLES }} --${{ env.STACK }} -v ${{ inputs.extra_args }}
105+
./scripts/tests all ${{ inputs.check_namespace == 'true' && '--check-namespace' || ''}} --exec-wrapper="${{ inputs.exec_wrapper }}" --cross-prefix="${{ inputs.cross_prefix }}" --cflags="${{ inputs.cflags }}" --ldflags="${{ inputs.ldflags }}" --opt=${{ inputs.opt }} --${{ env.FUNC }} --${{ env.KAT }} --${{ env.ACVP }} --${{ env.EXAMPLES }} --${{ env.STACK }} -v ${{ inputs.extra_args }}
103106
- name: Post ${{ env.MODE }} Tests
104107
shell: ${{ env.SHELL }}
105108
if: success() || failure()

.github/actions/multi-functest/action.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ inputs:
2222
cflags:
2323
description: CFLAGS to pass to compilation
2424
default: ""
25+
ldflags:
26+
description: LDFLAGS to pass to linking
27+
default: ""
2528
compile_mode:
2629
description: all | native | cross-x86_64 | cross-aarch64 | cross-riscv64 | cross-riscv32
2730
default: "native"
@@ -62,6 +65,7 @@ runs:
6265
gh_token: ${{ inputs.gh_token }}
6366
custom_shell: ${{ inputs.custom_shell }}
6467
cflags: ${{ inputs.cflags }}
68+
ldflags: ${{ inputs.ldflags }}
6569
opt: ${{ inputs.opt }}
6670
func: ${{ inputs.func }}
6771
kat: ${{ inputs.kat }}
@@ -80,6 +84,7 @@ runs:
8084
gh_token: ${{ inputs.gh_token }}
8185
custom_shell: ${{ inputs.custom_shell }}
8286
cflags: "${{ inputs.cflags }} -DMLK_FORCE_X86_64"
87+
ldflags: ${{ inputs.ldflags }}
8388
cross_prefix: x86_64-unknown-linux-gnu-
8489
exec_wrapper: qemu-x86_64
8590
opt: ${{ inputs.opt }}
@@ -100,6 +105,7 @@ runs:
100105
gh_token: ${{ inputs.gh_token }}
101106
custom_shell: ${{ inputs.custom_shell }}
102107
cflags: "${{ inputs.cflags }} -DMLK_FORCE_AARCH64"
108+
ldflags: ${{ inputs.ldflags }}
103109
cross_prefix: aarch64-unknown-linux-gnu-
104110
exec_wrapper: qemu-aarch64
105111
opt: ${{ inputs.opt }}
@@ -120,6 +126,7 @@ runs:
120126
gh_token: ${{ inputs.gh_token }}
121127
custom_shell: ${{ inputs.custom_shell }}
122128
cflags: "${{ inputs.cflags }} -DMLK_FORCE_PPC64LE"
129+
ldflags: ${{ inputs.ldflags }}
123130
cross_prefix: powerpc64le-unknown-linux-gnu-
124131
exec_wrapper: qemu-ppc64le
125132
opt: ${{ inputs.opt }}
@@ -140,6 +147,7 @@ runs:
140147
gh_token: ${{ inputs.gh_token }}
141148
custom_shell: ${{ inputs.custom_shell }}
142149
cflags: "${{ inputs.cflags }} -static -DMLK_FORCE_AARCH64_EB"
150+
ldflags: "${{ inputs.ldflags }} -static"
143151
cross_prefix: aarch64_be-none-linux-gnu-
144152
exec_wrapper: qemu-aarch64_be
145153
opt: ${{ inputs.opt }}
@@ -160,6 +168,7 @@ runs:
160168
gh_token: ${{ inputs.gh_token }}
161169
custom_shell: ${{ inputs.custom_shell }}
162170
cflags: "${{ inputs.cflags }} -DMLK_FORCE_RISCV64"
171+
ldflags: ${{ inputs.ldflags }}
163172
cross_prefix: riscv64-unknown-linux-gnu-
164173
exec_wrapper: qemu-riscv64
165174
opt: ${{ inputs.opt }}
@@ -180,6 +189,7 @@ runs:
180189
gh_token: ${{ inputs.gh_token }}
181190
custom_shell: ${{ inputs.custom_shell }}
182191
cflags: "${{ inputs.cflags }} -DMLK_FORCE_RISCV32"
192+
ldflags: ${{ inputs.ldflags }}
183193
cross_prefix: riscv32-unknown-linux-gnu-
184194
exec_wrapper: qemu-riscv32
185195
opt: ${{ inputs.opt }}

.github/workflows/bench.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,31 @@ jobs:
3232
bench_pmu: PMU
3333
archflags: -mcpu=cortex-a72 -DMLK_SYS_AARCH64_SLOW_BARREL_SHIFTER
3434
cflags: "-flto -DMLK_FORCE_AARCH64"
35+
ldflags: "-flto"
3536
bench_extra_args: ""
3637
nix_shell: ci-bench
3738
- system: rpi5
3839
name: Arm Cortex-A76 (Raspberry Pi 5) benchmarks
3940
bench_pmu: PERF
4041
archflags: "-mcpu=cortex-a76 -march=armv8.2-a"
4142
cflags: "-flto -DMLK_FORCE_AARCH64"
43+
ldflags: "-flto"
4244
bench_extra_args: ""
4345
nix_shell: ci-bench
4446
- system: a55
4547
name: Arm Cortex-A55 (Snapdragon 888) benchmarks
4648
bench_pmu: PERF
4749
archflags: "-mcpu=cortex-a55 -march=armv8.2-a"
48-
cflags: "-flto -static -DMLK_FORCE_AARCH64 -DMLK_CONFIG_FIPS202_BACKEND_FILE=\\\\\\\"fips202/native/aarch64/x1_scalar.h\\\\\\\""
50+
cflags: "-flto -DMLK_FORCE_AARCH64 -DMLK_CONFIG_FIPS202_BACKEND_FILE=\\\\\\\"fips202/native/aarch64/x1_scalar.h\\\\\\\""
51+
ldflags: "-flto -static"
4952
bench_extra_args: -w exec-on-a55
5053
nix_shell: ci-bench
5154
- system: bpi
5255
name: SpacemiT K1 8 (Banana Pi F3) benchmarks
5356
bench_pmu: PERF
5457
archflags: "-march=rv64imafdcv_zicsr_zifencei"
55-
cflags: "-static"
58+
cflags: ""
59+
ldflags: "-static"
5660
bench_extra_args: -w exec-on-bpi
5761
cross_prefix: riscv64-unknown-linux-gnu-
5862
nix_shell: ci-cross-riscv64
@@ -61,6 +65,7 @@ jobs:
6165
bench_pmu: MAC
6266
archflags: "-mcpu=apple-m1 -march=armv8.4-a+sha3"
6367
cflags: "-flto"
68+
ldflags: "-flto"
6469
bench_extra_args: "-r"
6570
nix_shell: ci-bench
6671
if: github.repository_owner == 'pq-code-package' && (github.event.label.name == 'benchmark' || github.ref == 'refs/heads/main')
@@ -72,6 +77,7 @@ jobs:
7277
name: ${{ matrix.target.name }}
7378
cflags: ${{ matrix.target.cflags }}
7479
archflags: ${{ matrix.target.archflags }}
80+
ldflags: ${{ matrix.target.ldflags }}
7581
perf: ${{ matrix.target.bench_pmu }}
7682
store_results: ${{ github.repository_owner == 'pq-code-package' && github.ref == 'refs/heads/main' }}
7783
bench_extra_args: ${{ matrix.target.bench_extra_args }}
@@ -94,42 +100,49 @@ jobs:
94100
ec2_ami: ubuntu-latest (aarch64)
95101
archflags: -mcpu=cortex-a76 -march=armv8.2-a
96102
cflags: "-flto -DMLK_FORCE_AARCH64"
103+
ldflags: "-flto"
97104
perf: PERF
98105
- name: Graviton3
99106
ec2_instance_type: c7g.medium
100107
ec2_ami: ubuntu-latest (aarch64)
101108
archflags: -march=armv8.4-a+sha3
102109
cflags: "-flto -DMLK_FORCE_AARCH64"
110+
ldflags: "-flto"
103111
perf: PERF
104112
- name: Graviton4
105113
ec2_instance_type: c8g.medium
106114
ec2_ami: ubuntu-latest (aarch64)
107115
archflags: -march=armv9-a+sha3
108116
cflags: "-flto -DMLK_FORCE_AARCH64"
117+
ldflags: "-flto"
109118
perf: PERF
110119
- name: AMD EPYC 4th gen (c7a)
111120
ec2_instance_type: c7a.medium
112121
ec2_ami: ubuntu-latest (x86_64)
113122
archflags: -mavx2 -mbmi2 -mpopcnt -march=znver4
114123
cflags: "-flto -DMLK_FORCE_X86_64"
124+
ldflags: "-flto"
115125
perf: PMU
116126
- name: Intel Xeon 4th gen (c7i)
117127
ec2_instance_type: c7i.metal-24xl
118128
ec2_ami: ubuntu-latest (x86_64)
119129
archflags: -mavx2 -mbmi2 -mpopcnt -march=sapphirerapids
120130
cflags: "-flto -DMLK_FORCE_X86_64"
131+
ldflags: "-flto"
121132
perf: PMU
122133
- name: AMD EPYC 3rd gen (c6a)
123134
ec2_instance_type: c6a.large
124135
ec2_ami: ubuntu-latest (x86_64)
125136
archflags: -mavx2 -mbmi2 -mpopcnt -march=znver3
126137
cflags: "-flto -DMLK_FORCE_X86_64"
138+
ldflags: "-flto"
127139
perf: PMU
128140
- name: Intel Xeon 3rd gen (c6i)
129141
ec2_instance_type: c6i.large
130142
ec2_ami: ubuntu-latest (x86_64)
131143
archflags: -mavx2 -mbmi2 -mpopcnt -march=icelake-server
132144
cflags: "-flto -DMLK_FORCE_X86_64"
145+
ldflags: "-flto"
133146
perf: PMU
134147
uses: ./.github/workflows/bench_ec2_reusable.yml
135148
if: github.repository_owner == 'pq-code-package' && (github.event.label.name == 'benchmark' || github.ref == 'refs/heads/main')
@@ -138,6 +151,7 @@ jobs:
138151
ec2_ami: ${{ matrix.target.ec2_ami }}
139152
archflags: ${{ matrix.target.archflags }}
140153
cflags: ${{ matrix.target.cflags }}
154+
ldflags: ${{ matrix.target.ldflags }}
141155
opt: "all"
142156
store_results: ${{ github.repository_owner == 'pq-code-package' && github.ref == 'refs/heads/main' }} # Only store optimized results
143157
name: ${{ matrix.target.name }}

.github/workflows/bench_ec2_any.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ on:
3030
archflags:
3131
description: Custom ARCH flags for compilation
3232
default: ''
33+
ldflags:
34+
description: Custom LDFLAGS for linking
35+
default: ''
3336
opt:
3437
description: Benchmark optimized, non-optimized, or both
3538
type: choice
@@ -58,6 +61,7 @@ jobs:
5861
ec2_ami: ${{ inputs.ec2_ami }}
5962
ec2_ami_id: ${{ inputs.ec2_ami_id }}
6063
cflags: ${{ inputs.cflags }}
64+
ldflags: ${{ inputs.ldflags }}
6165
archflags: ${{ inputs.archflags }}
6266
opt: ${{ inputs.opt }}
6367
name: ${{ inputs.name }}

.github/workflows/bench_ec2_reusable.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ on:
2828
type: string
2929
description: Custom ARCH flags for compilation
3030
default: -mcpu=neoverse-n1 -march=armv8.2-a
31+
ldflags:
32+
type: string
33+
description: Custom LDFLAGS for linking
34+
default: ""
3135
opt:
3236
type: string
3337
description: Runs with optimized code if enabled (opt, no_opt, all)
@@ -131,6 +135,7 @@ jobs:
131135
name: ${{ inputs.name }}
132136
cflags: ${{ inputs.cflags }}
133137
archflags: ${{ inputs.archflags }}
138+
ldflags: ${{ inputs.ldflags }}
134139
opt: true
135140
perf: ${{ inputs.perf }}
136141
store_results: ${{ inputs.store_results }}
@@ -143,6 +148,7 @@ jobs:
143148
name: ${{ inputs.name }} (no-opt)
144149
cflags: ${{ inputs.cflags }}
145150
archflags: ${{ inputs.archflags }}
151+
ldflags: ${{ inputs.ldflags }}
146152
opt: false
147153
perf: ${{ inputs.perf }}
148154
store_results: ${{ inputs.store_results }}
@@ -175,6 +181,7 @@ jobs:
175181
name: ${{ inputs.name }} (${{ inputs.compiler }})
176182
cflags: ${{ inputs.cflags }}
177183
archflags: ${{ inputs.archflags }}
184+
ldflags: ${{ inputs.ldflags }}
178185
opt: true
179186
perf: ${{ inputs.perf }}
180187
store_results: ${{ inputs.store_results }}
@@ -190,6 +197,7 @@ jobs:
190197
name: ${{ inputs.name }} (${{ inputs.compiler }}) (no-opt)
191198
cflags: ${{ inputs.cflags }}
192199
archflags: ${{ inputs.archflags }}
200+
ldflags: ${{ inputs.ldflags }}
193201
opt: false
194202
perf: ${{ inputs.perf }}
195203
store_results: ${{ inputs.store_results }}

0 commit comments

Comments
 (0)