Skip to content

bootstrap should set optimization level when calculating cflags #48906

Closed
@comex

Description

@comex

bootstrap/builder.rs uses cc-rs to get a list of cflags for the target, which it then passes to cargo build as CFLAGS_<target>. As of rust-lang/cc-rs#294, the flags can depend on the optimization level: on iOS, with optimization disabled it passes -fembed-bitcode -fembed-bitcode-marker, but with optimization enabled it passes only -fembed-bitcode. However, bootstrap seems to always pass -fembed-bitcode-marker.

Note that some of the crates in the build, such as libcompiler_builtins and libbacktrace, use cc-rs themselves, causing a second set of cflags to be appended to the cc command line, identical except for respecting the optimization level. This seems odd, although it doesn't seem to cause any problems in itself.

Example build log:

OPT_LEVEL = Some("2")
TARGET = Some("aarch64-apple-ios")
CC_aarch64-apple-ios = Some("cc")
CFLAGS_aarch64-apple-ios = Some("-fPIC -arch arm64
-miphoneos-version-min=7.0 -isysroot
/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.3.sdk
-fembed-bitcode -fembed-bitcode-marker")
Detecting iOS SDK path for iphoneos
running: "cc" "-O2" "-fPIC" "-fPIC" "-arch" "arm64"
"-miphoneos-version-min=7.0" "-isysroot"
"/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.3.sdk"
"-fembed-bitcode" "-fembed-bitcode-marker" "-arch" "arm64"
"-miphoneos-version-min=7.0" "-isysroot"
"/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.3.sdk"
"-fembed-bitcode" "-fno-builtin" "-fvisibility=hidden" "-ffreestanding"
"-fomit-frame-pointer" "-DVISIBILITY_HIDDEN" "-o"
"/tmp/build/x86_64-apple-darwin/stage2-std/aarch64-apple-ios/release/build/compiler_builtins-d5d18ec9ecb6ca67/out/../../libcompiler_builtins/compiler-rt/lib/builtins/absvdi2.o"
"-c" "../../libcompiler_builtins/compiler-rt/lib/builtins/absvdi2.c"

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions