Skip to content

Commit 3f5d7de

Browse files
authored
Expose cc-rs no_default_flags for hassle-free cross-compilation (#225)
1 parent b689783 commit 3f5d7de

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/lib.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ pub struct Config {
7777
uses_cxx11: bool,
7878
always_configure: bool,
7979
no_build_target: bool,
80+
no_default_flags: bool,
8081
verbose_cmake: bool,
8182
verbose_make: bool,
8283
pic: Option<bool>,
@@ -184,6 +185,7 @@ impl Config {
184185
path: env::current_dir().unwrap().join(path),
185186
generator: None,
186187
generator_toolset: None,
188+
no_default_flags: false,
187189
cflags: OsString::new(),
188190
cxxflags: OsString::new(),
189191
asmflags: OsString::new(),
@@ -297,6 +299,13 @@ impl Config {
297299
self
298300
}
299301

302+
/// Disables the generation of default compiler flags. The default compiler
303+
/// flags may cause conflicts in some cross compiling scenarios.
304+
pub fn no_default_flags(&mut self, no_default_flags: bool) -> &mut Config {
305+
self.no_default_flags = no_default_flags;
306+
self
307+
}
308+
300309
/// Sets the host triple for this compilation.
301310
///
302311
/// This is automatically scraped from `$HOST` which is set for Cargo
@@ -515,7 +524,7 @@ impl Config {
515524
.debug(false)
516525
.warnings(false)
517526
.host(&host)
518-
.no_default_flags(ndk);
527+
.no_default_flags(ndk || self.no_default_flags);
519528
if !ndk {
520529
c_cfg.target(&target);
521530
}
@@ -527,7 +536,7 @@ impl Config {
527536
.debug(false)
528537
.warnings(false)
529538
.host(&host)
530-
.no_default_flags(ndk);
539+
.no_default_flags(ndk || self.no_default_flags);
531540
if !ndk {
532541
cxx_cfg.target(&target);
533542
}

0 commit comments

Comments
 (0)