rust-secure-code / cargo-supply-chain

Gather author, contributor and publisher data on crates in your dependency graph.
Apache License 2.0
313 stars 18 forks source link

Strict `CFLAGS` break the build #43

Closed noncombatant closed 3 years ago

noncombatant commented 3 years ago

This is probably really a ring bug. (Or, WontFix, if I am too weird.) Let me know if you think I should file it there, too.

I use weird CFLAGS because I am a weirdo:

~/src/rust/cargo-supply-chain % echo $CFLAGS
-Weverything -Werror -O0 -std=c11

I'm on macOS with clang:

~/src/rust/cargo-supply-chain % clang --version
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin20.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

I leave them in my standard shell environment just to enjoy the explosions. Here's how ring explodes:

error: failed to run custom build command for `ring v0.16.20`

Caused by:
  process didn't exit successfully: `/Users/chris/src/rust/cargo-supply-chain/target/debug/build/ring-f05a2e2ad93a365a/build-script-build` (exit code: 101)
  --- stdout
  OPT_LEVEL = Some("0")
  TARGET = Some("x86_64-apple-darwin")
  HOST = Some("x86_64-apple-darwin")
  CC_x86_64-apple-darwin = None
  CC_x86_64_apple_darwin = None
  HOST_CC = None
  CC = Some("clang")
  CFLAGS_x86_64-apple-darwin = None
  CFLAGS_x86_64_apple_darwin = None
  HOST_CFLAGS = None
  CFLAGS = Some("-Weverything -Werror -O0 -std=c11")
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")

  --- stderr
  running "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=x86_64-apple-darwin" "-Weverything" "-Werror" "-O0" "-std=c11" "-I" "include" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-gfull" "-DNDEBUG" "-c" "-o/Users/chris/src/rust/cargo-supply-chain/target/debug/build/ring-7381a064665e3f2d/out/aesni-x86_64-macosx.o" "/Users/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/pregenerated/aesni-x86_64-macosx.S"
  error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
  <built-in>:93:9: error: macro is not used [-Werror,-Wunused-macros]
  #define __SIG_ATOMIC_MAX__ 2147483647
          ^
  <built-in>:343:9: error: macro is not used [-Werror,-Wunused-macros]
  #define __SSE2_MATH__ 1
          ^
  <built-in>:341:9: error: macro is not used [-Werror,-Wunused-macros]
  #define __SSE3__ 1
          ^
  <built-in>:305:9: error: macro is not used [-Werror,-Wunused-macros]
  #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2
          ^
  <built-in>:342:9: error: macro is not used [-Werror,-Wunused-macros]
  #define __SSE2__ 1
          ^
  <built-in>:94:9: error: macro is not used [-Werror,-Wunused-macros]
  #define __CHAR16_TYPE__ unsigned short
          ^
  <built-in>:288:9: error: macro is not used [-Werror,-Wunused-macros]
  #define __UINT_FAST64_FMTX__ "llX"
          ^
  <built-in>:95:9: error: macro is not used [-Werror,-Wunused-macros]
  #define __CHAR32_TYPE__ unsigned int
          ^
  <built-in>:345:9: error: macro is not used [-Werror,-Wunused-macros]
  #define __SSE_MATH__ 1
          ^
  <built-in>:96:9: error: macro is not used [-Werror,-Wunused-macros]
  #define __UINTMAX_WIDTH__ 64
          ^
  <built-in>:347:9: error: macro is not used [-Werror,-Wunused-macros]
  #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
          ^
  <built-in>:97:9: error: macro is not used [-Werror,-Wunused-macros]
  #define __UINTPTR_TYPE__ long unsigned int
          ^
  <built-in>:98:9: error: macro is not used [-Werror,-Wunused-macros]
  #define __UINTPTR_FMTo__ "lo"
          ^
  <built-in>:99:9: error: macro is not used [-Werror,-Wunused-macros]
  #define __UINTPTR_FMTu__ "lu"
          ^
  <built-in>:346:9: error: macro is not used [-Werror,-Wunused-macros]
  #define __MMX__ 1
          ^
  <built-in>:344:9: error: macro is not used [-Werror,-Wunused-macros]
  #define __SSE__ 1
          ^
  <built-in>:83:9: error: macro is not used [-Werror,-Wunused-macros]
  #define __SIZE_FMTo__ "lo"
          ^
  <built-in>:348:9: error: macro is not used [-Werror,-Wunused-macros]
  #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
          ^
  fatal error: too many errors emitted, stopping now [-ferror-limit=]
  20 errors generated.
  thread 'main' panicked at 'execution failed', /Users/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/build.rs:656:9
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed
noncombatant commented 3 years ago

I should add that, yes, unset CFLAGS causes the build to work just fine.

noncombatant commented 3 years ago

It's probably not even a ring issue, really.

Shnatsel commented 3 years ago

Thanks for the report! This is not directly actionable for cargo supply-chain, but ring might be interested in the report.

I see that it includes no AVX, so I suspect this is due to the way ring selects an optimized implementation. Then again, maybe there is a bit of dead code after all!