Skip to content

Commit daecb5e

Browse files
committed
Remove shared_flag and static_flag
They are meaningless since cc-rs only generates static libraries. Having them does nothing and only causes confusion. Closes #1444 Closes #594
1 parent 6fb2a8f commit daecb5e

File tree

3 files changed

+5
-85
lines changed

3 files changed

+5
-85
lines changed

src/lib.rs

Lines changed: 5 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,6 @@ pub struct Build {
413413
pic: Option<bool>,
414414
use_plt: Option<bool>,
415415
static_crt: Option<bool>,
416-
shared_flag: Option<bool>,
417-
static_flag: Option<bool>,
418416
warnings_into_errors: bool,
419417
warnings: Option<bool>,
420418
extra_warnings: Option<bool>,
@@ -519,8 +517,6 @@ impl Build {
519517
asm_flags: Vec::new(),
520518
no_default_flags: false,
521519
files: Vec::new(),
522-
shared_flag: None,
523-
static_flag: None,
524520
cpp: false,
525521
cpp_link_stdlib: None,
526522
cpp_link_stdlib_static: false,
@@ -781,43 +777,6 @@ impl Build {
781777
Ok(self)
782778
}
783779

784-
/// Set the `-shared` flag.
785-
///
786-
/// When enabled, the compiler will produce a shared object which can
787-
/// then be linked with other objects to form an executable.
788-
///
789-
/// # Example
790-
///
791-
/// ```no_run
792-
/// cc::Build::new()
793-
/// .file("src/foo.c")
794-
/// .shared_flag(true)
795-
/// .compile("libfoo.so");
796-
/// ```
797-
pub fn shared_flag(&mut self, shared_flag: bool) -> &mut Build {
798-
self.shared_flag = Some(shared_flag);
799-
self
800-
}
801-
802-
/// Set the `-static` flag.
803-
///
804-
/// When enabled on systems that support dynamic linking, this prevents
805-
/// linking with the shared libraries.
806-
///
807-
/// # Example
808-
///
809-
/// ```no_run
810-
/// cc::Build::new()
811-
/// .file("src/foo.c")
812-
/// .shared_flag(true)
813-
/// .static_flag(true)
814-
/// .compile("foo");
815-
/// ```
816-
pub fn static_flag(&mut self, static_flag: bool) -> &mut Build {
817-
self.static_flag = Some(static_flag);
818-
self
819-
}
820-
821780
/// Disables the generation of default compiler flags. The default compiler
822781
/// flags may cause conflicts in some cross compiling scenarios.
823782
///
@@ -1032,9 +991,8 @@ impl Build {
1032991
/// ```no_run
1033992
/// cc::Build::new()
1034993
/// .file("src/foo.c")
1035-
/// .shared_flag(true)
1036994
/// .cpp_link_stdlib("stdc++")
1037-
/// .compile("libfoo.so");
995+
/// .compile("foo");
1038996
/// ```
1039997
pub fn cpp_link_stdlib<'a, V: Into<Option<&'a str>>>(
1040998
&mut self,
@@ -2313,12 +2271,10 @@ impl Build {
23132271
cmd.args.push("-finput-charset=utf-8".into());
23142272
}
23152273

2316-
if self.static_flag.is_none() {
2317-
let features = self.getenv("CARGO_CFG_TARGET_FEATURE");
2318-
let features = features.as_deref().unwrap_or_default();
2319-
if features.to_string_lossy().contains("crt-static") {
2320-
cmd.args.push("-static".into());
2321-
}
2274+
let features = self.getenv("CARGO_CFG_TARGET_FEATURE");
2275+
let features = features.as_deref().unwrap_or_default();
2276+
if features.to_string_lossy().contains("crt-static") {
2277+
cmd.args.push("-static".into());
23222278
}
23232279

23242280
// armv7 targets get to use armv7 instructions
@@ -2506,13 +2462,6 @@ impl Build {
25062462
self.apple_flags(cmd)?;
25072463
}
25082464

2509-
if self.static_flag.unwrap_or(false) {
2510-
cmd.args.push("-static".into());
2511-
}
2512-
if self.shared_flag.unwrap_or(false) {
2513-
cmd.args.push("-shared".into());
2514-
}
2515-
25162465
if self.cpp {
25172466
match (self.cpp_set_stdlib.as_ref(), cmd.family) {
25182467
(None, _) => {}

tests/cflags.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ fn cflags_order() {
3838
let test = Test::gnu();
3939
test.gcc()
4040
.target("x86_64-unknown-none")
41-
.static_flag(true)
4241
.flag("-Lbuilder-flag1")
4342
.flag("-Lbuilder-flag2")
4443
.file("foo.c")

tests/test.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -340,20 +340,6 @@ fn gnu_compile_assembly() {
340340
test.cmd(0).must_have("foo.S");
341341
}
342342

343-
#[test]
344-
fn gnu_shared() {
345-
reset_env();
346-
347-
let test = Test::gnu();
348-
test.gcc()
349-
.file("foo.c")
350-
.shared_flag(true)
351-
.static_flag(false)
352-
.compile("foo");
353-
354-
test.cmd(0).must_have("-shared").must_not_have("-static");
355-
}
356-
357343
#[test]
358344
fn gnu_flag_if_supported() {
359345
reset_env();
@@ -390,20 +376,6 @@ fn gnu_flag_if_supported_cpp() {
390376
test.cmd(0).must_have("-std=c++11");
391377
}
392378

393-
#[test]
394-
fn gnu_static() {
395-
reset_env();
396-
397-
let test = Test::gnu();
398-
test.gcc()
399-
.file("foo.c")
400-
.shared_flag(false)
401-
.static_flag(true)
402-
.compile("foo");
403-
404-
test.cmd(0).must_have("-static").must_not_have("-shared");
405-
}
406-
407379
#[test]
408380
fn gnu_no_dash_dash() {
409381
let test = Test::gnu();

0 commit comments

Comments
 (0)