Skip to content

bootstrap overrides -O in CFLAGS for LLVM #39900

@semarie

Description

@semarie

At OpenBSD, for building lang/rust package, we switched from using standard LLVM version (3.9.1) to embedded LLVM version, in order to be able to update LLVM at 4.0.0.

The switch has a big performance impact: the build of rust passed from approx 2h (build with linking to external LLVM) to 12h (with 2h for building LLVM itself). And every program built with rustc had a similar performance impact (build time for cargo raise by a factor of 8).

I passed lot of time to found the issue (comparing source tree between stock LLVM-3.9.1 and src/llvm, reviewing cmake options and finally comparing compiler command-line). It appeared that LLVM embedded version is build without optimization (no -O2 in CFLAGS).

As workaround, I removed the filter out of -O options from bootstrap code, and the build time come back to something more coherent: only 4h (with 2h for LLVM itself - so it is similar to what we had before).

In order to check the LLVM comand-line at compilation, I also added cfg.define("CMAKE_VERBOSE_MAKEFILE", "ON"); to src/bootstrap/native.rs.

I dunno if the issue is only on OpenBSD or could be found on other platform. Maybe Linux adds some optimization by default on the compiler ? or it is LLVM that doesn't enable same optimizations set depending the platform ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)requires-custom-configThis issue requires custom config/build for rustc in some way

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions