Skip to content

Commit fc225d2

Browse files
bors[bot]DrTobe
andauthored
258: Fix 'cc --print-sysroot' call r=jethrogb a=DrTobe This PR contains two changes: 1. The first commit fixes a bug that the result of `cc --print-sysroot` is not properly checked before it is evaluated and added as a compiler flag. This one should be easy to accept. 2. The second commit is harder to accept because it changes code in the `vendor` directory which should probably stay untouched? I just did not know how to append a compiler flag to the CMake process without doing so. Without the new compiler flag `-Wno-unused-but-set-variable`, Apple clang 14 fails with the following error message and this conclusion seems to be _correct_: ``` mbedtls-sys/vendor/library/bignum.c:1395:29: error: variable 't' set but not used [-Werror,-Wunused-but-set-variable] mbedtls_mpi_uint c = 0, t = 0; ^ ``` So to fix builds for compilers which properly detect this, we need to somehow change the compiler flags for the C code. Setting it with `cmk.cflag(...)` in `mbedtls-sys/build/cmake.rs` did not work. I have thought about setting `CMAKE_C_FLAGS` before calling CMake but the new flag _must_ appear behind `-Wall` which is set by the `CMakeLists.txt` so I guess this will not work either. So how would you like to do this? Any other ideas? Edit: The second commit has been removed (see discussion) Co-authored-by: Tobias Naumann <[email protected]>
2 parents 95a2439 + 9664203 commit fc225d2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mbedtls-sys/build/bindgen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl super::BuildConfig {
104104
if compiler.is_like_gnu() {
105105
let output = compiler.to_command().args(&["--print-sysroot"]).output();
106106
match output {
107-
Ok(sysroot) => {
107+
Ok(sysroot) if sysroot.status.success() => {
108108
let path = std::str::from_utf8(&sysroot.stdout).expect("Malformed sysroot");
109109
let trimmed_path = path
110110
.strip_suffix("\r\n")

0 commit comments

Comments
 (0)