Skip to content

Commit 9861873

Browse files
committed
Add ldflags option
1 parent fdc8336 commit 9861873

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

crates/test/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,10 @@ separate crate and passed as `--extern`
314314

315315
#### Configuration: C
316316

317-
C/C++ configuration supports configuring compilation flags at this time:
317+
C/C++ configuration supports configuring compilation and linker flags at this time:
318318

319319
```rust
320320
//@ [lang]
321321
//@ cflags = '-O'
322+
//@ ldflags = "-Wl,--export-table"
322323
```

crates/test/src/c.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ struct LangConfig {
2828
/// Space-separated list or array of compiler flags to pass.
2929
#[serde(default)]
3030
cflags: StringList,
31+
/// Space-separated list or array of linker flags to pass.
32+
#[serde(default)]
33+
ldflags: StringList,
3134
}
3235

3336
fn clang(runner: &Runner<'_>) -> PathBuf {
@@ -139,12 +142,14 @@ fn compile(runner: &Runner<'_>, compile: &Compile<'_>, compiler: PathBuf) -> Res
139142
.arg("-Wc++-compat")
140143
.arg("-Wno-unused-parameter")
141144
.arg("-g")
142-
.arg("-Wl,--export-table")
143145
.arg("-o")
144146
.arg(&output);
145147
for flag in Vec::from(config.cflags) {
146148
cmd.arg(flag);
147149
}
150+
for flag in Vec::from(config.ldflags) {
151+
cmd.arg(flag);
152+
}
148153
cmd.arg("-mexec-model=reactor");
149154
if produces_component(runner) {
150155
cmd.arg("-Wl,--skip-wit-component");

tests/runtime-async/async/threading-builtins/test.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
//@ args = '--rename a:b/i=test'
2+
//@ [lang]
3+
//@ ldflags = "-Wl,--export-table"
24

35
#include <assert.h>
46
#include <test.h>

0 commit comments

Comments
 (0)