Skip to content

Commit 6632665

Browse files
committed
No-op shared_flag() and static_flag() methods.
The compiler flags enabled by the methods in question are link flags and are never actually used in the cc-rs context. The shared_flag() is documented as reserved for future support for linking shared libraries, and static_flag() is effectively deprecated.
1 parent b388631 commit 6632665

File tree

2 files changed

+4
-58
lines changed

2 files changed

+4
-58
lines changed

src/lib.rs

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,8 @@ impl Build {
597597

598598
/// Set the `-shared` flag.
599599
///
600-
/// When enabled, the compiler will produce a shared object which can
601-
/// then be linked with other objects to form an executable.
600+
/// The method is reserved for linking a shared library, currently
601+
/// a no-op.
602602
///
603603
/// # Example
604604
///
@@ -615,18 +615,8 @@ impl Build {
615615

616616
/// Set the `-static` flag.
617617
///
618-
/// When enabled on systems that support dynamic linking, this prevents
619-
/// linking with the shared libraries.
618+
/// This is a no-op method retained for backward compatibility.
620619
///
621-
/// # Example
622-
///
623-
/// ```no_run
624-
/// cc::Build::new()
625-
/// .file("src/foo.c")
626-
/// .shared_flag(true)
627-
/// .static_flag(true)
628-
/// .compile("foo");
629-
/// ```
630620
pub fn static_flag(&mut self, static_flag: bool) -> &mut Build {
631621
self.static_flag = Some(static_flag);
632622
self
@@ -798,9 +788,8 @@ impl Build {
798788
/// ```no_run
799789
/// cc::Build::new()
800790
/// .file("src/foo.c")
801-
/// .shared_flag(true)
802791
/// .cpp_link_stdlib("stdc++")
803-
/// .compile("libfoo.so");
792+
/// .compile("foo");
804793
/// ```
805794
pub fn cpp_link_stdlib<'a, V: Into<Option<&'a str>>>(
806795
&mut self,
@@ -1843,14 +1832,6 @@ impl Build {
18431832
cmd.args.push("-finput-charset=utf-8".into());
18441833
}
18451834

1846-
if self.static_flag.is_none() {
1847-
let features = self.getenv("CARGO_CFG_TARGET_FEATURE");
1848-
let features = features.as_deref().unwrap_or_default();
1849-
if features.contains("crt-static") {
1850-
cmd.args.push("-static".into());
1851-
}
1852-
}
1853-
18541835
// armv7 targets get to use armv7 instructions
18551836
if (target.starts_with("armv7") || target.starts_with("thumbv7"))
18561837
&& (target.contains("-linux-") || target.contains("-kmc-solid_"))
@@ -2031,13 +2012,6 @@ impl Build {
20312012
self.ios_watchos_flags(cmd)?;
20322013
}
20332014

2034-
if self.static_flag.unwrap_or(false) {
2035-
cmd.args.push("-static".into());
2036-
}
2037-
if self.shared_flag.unwrap_or(false) {
2038-
cmd.args.push("-shared".into());
2039-
}
2040-
20412015
if self.cpp {
20422016
match (self.cpp_set_stdlib.as_ref(), cmd.family) {
20432017
(None, _) => {}

tests/test.rs

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

295-
#[test]
296-
fn gnu_shared() {
297-
reset_env();
298-
299-
let test = Test::gnu();
300-
test.gcc()
301-
.file("foo.c")
302-
.shared_flag(true)
303-
.static_flag(false)
304-
.compile("foo");
305-
306-
test.cmd(0).must_have("-shared").must_not_have("-static");
307-
}
308-
309295
#[test]
310296
fn gnu_flag_if_supported() {
311297
reset_env();
@@ -344,20 +330,6 @@ fn gnu_flag_if_supported_cpp() {
344330
test.cmd(0).must_have("-std=c++11");
345331
}
346332

347-
#[test]
348-
fn gnu_static() {
349-
reset_env();
350-
351-
let test = Test::gnu();
352-
test.gcc()
353-
.file("foo.c")
354-
.shared_flag(false)
355-
.static_flag(true)
356-
.compile("foo");
357-
358-
test.cmd(0).must_have("-static").must_not_have("-shared");
359-
}
360-
361333
#[test]
362334
fn gnu_no_dash_dash() {
363335
let test = Test::gnu();

0 commit comments

Comments
 (0)