Closed Bug 1704580 Opened 3 years ago Closed 3 years ago

SW-WR should not be optimized in no-opt builds

Categories

(Firefox Build System :: General, defect)

defect

Tracking

(firefox90 fixed)

RESOLVED FIXED
90 Branch
Tracking Status
firefox90 --- fixed

People

(Reporter: tsmith, Assigned: glandium)

References

Details

Attachments

(2 files)

This makes Pernosco sessions unhelpful in some cases.

Log from no-opt build:

[task 2021-04-12T16:23:43.939Z] 16:23:43     INFO -  [swgl 0.1.0] running: "/builds/worker/fetches/sccache/sccache" "/builds/worker/fetches/clang/bin/clang++" "-O1" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=x86_64-unknown-linux-gnu" "--sysroot" "/builds/worker/fetches/sysroot" "-std=gnu++17" "-I/builds/worker/workspace/obj-build/dist/stl_wrappers" "-I/builds/worker/workspace/obj-build/dist/system_wrappers" "-include" "/builds/worker/checkouts/gecko/config/gcc_hidden.h" "-fstack-protector-strong" "-fstack-clash-protection" "-ftrivial-auto-var-init=pattern" "-DDEBUG=1" "-I/builds/worker/checkouts/gecko/toolkit/library/gtest/rust" "-I/builds/worker/workspace/obj-build/toolkit/library/gtest/rust" "-I/builds/worker/workspace/obj-build/dist/include" "-I/builds/worker/workspace/obj-build/dist/include/nspr" "-I/builds/worker/workspace/obj-build/dist/include/nss" "-DMOZILLA_CLIENT" "-include" "/builds/worker/workspace/obj-build/mozilla-config.h" "-Qunused-arguments" "-Qunused-arguments" "-Wall" "-Wbitfield-enum-conversion" "-Wempty-body" "-Wignored-qualifiers" "-Woverloaded-virtual" "-Wpointer-arith" "-Wshadow-field-in-constructor-modified" "-Wsign-compare" "-Wtype-limits" "-Wunreachable-code" "-Wunreachable-code-return" "-Wwrite-strings" "-Wno-invalid-offsetof" "-Wclass-varargs" "-Wempty-init-stmt" "-Wfloat-overflow-conversion" "-Wfloat-zero-conversion" "-Wloop-analysis" "-Wno-range-loop-analysis" "-Wc++2a-compat" "-Wcomma" "-Wimplicit-fallthrough" "-Wunused-function" "-Wunused-variable" "-Werror=non-literal-null-conversion" "-Wstring-conversion" "-Wtautological-overlap-compare" "-Wtautological-unsigned-enum-zero-compare" "-Wtautological-unsigned-zero-compare" "-Wno-error=tautological-type-limit-compare" "-Wno-inline-new-delete" "-Wno-error=deprecated-declarations" "-Wno-error=array-bounds" "-Wno-error=backend-plugin" "-Wno-error=return-std-move" "-Wno-error=atomic-alignment" "-Wno-error=deprecated-copy" "-Wformat" "-Wformat-security" "-Wno-gnu-zero-variadic-macro-arguments" "-Wno-psabi" "-Wno-unknown-warning-option" "-D_GLIBCXX_USE_CXX11_ABI=0" "-fno-sized-deallocation" "-fno-aligned-new" "-fcrash-diagnostics-dir=/builds/worker/artifacts" "-fno-exceptions" "-fno-strict-aliasing" "-fPIC" "-fno-rtti" "-ffunction-sections" "-fdata-sections" "-fno-exceptions" "-fno-math-errno" "-pthread" "-pipe" "-g" "-Xclang" "-load" "-Xclang" "/builds/worker/workspace/obj-build/build/clang-plugin/libclang-plugin.so" "-Xclang" "-add-plugin" "-Xclang" "moz-check" "-fno-omit-frame-pointer" "-funwind-tables" "-fexperimental-new-pass-manager" "-DMOZILLA_CONFIG_H" "-I" "/builds/worker/checkouts/gecko/gfx/wr/webrender/res" "-I" "src" "-I" "/builds/worker/workspace/obj-build/x86_64-unknown-linux-gnu/debug/build/swgl-9ed5e1e3cbda9984/out" "-std=c++17" "-fno-exceptions" "-fno-rtti" "-fno-math-errno" "-UMOZILLA_CONFIG_H" "-ffast-math" "-mrecip=none" "-D_GLIBCXX_USE_CXX11_ABI=0" "-o" "/builds/worker/workspace/obj-build/x86_64-unknown-linux-gnu/debug/build/swgl-9ed5e1e3cbda9984/out/src/gl.o" "-c" "src/gl.cc"
Summary: SW-WR is optimized in no-opt builds → SW-WR should not be optimized in no-opt builds

(Going from the logs in m-c/2021-01-28/linux64-noopt-debug and m-c/2021-01-29/linux64-noopt-debug, and assuming bug 1689284 is the relevant change between those two)

Prior to bug 1689284, the command for building swgl includes:

rustc ... gfx/wr/swgl/src/lib.rs ... -C opt-level=1 ... -C opt-level=2 ...

After bug 1689284, the command changes to:

rustc ... gfx/wr/swgl/src/lib.rs ... -C opt-level=1 ... -C opt-level=0 ...

The latter is better, but unfortunately rustc prefers the first setting, as evidenced by OPT_LEVEL=1 in both builds. I'd guess the first -C opt-level=1 is coming from the root Cargo.toml.

Mike, any idea how to fix this?

Flags: needinfo?(mh+mozilla)
See Also: → 1689284

This turns out to be a cargo problem. Because with -C opt-level=$foo -C opt-level=$bar, rust will use $bar. But cargo sets OPT_LEVEL to $foo when it calls the build script. Filed https://github.com/rust-lang/cargo/issues/9358.

The only way out of this might be to set the opt-level a different way, like using CARGO_PROFILE_RELEASE_OPT_LEVEL, although I'm not 100% sure what version of cargo started supporting those, and we'd have to be careful about what profile is used.

Flags: needinfo?(mh+mozilla)
Assignee: nobody → mh+mozilla
Status: NEW → ASSIGNED

Setting it via -C opt-level makes us hit
https://github.com/rust-lang/cargo/issues/9358 so use an alternative
way, that works since rust version 1.43.0.

Pushed by mh@glandium.org:
https://hg.mozilla.org/integration/autoland/rev/1c254c5e7207
Move various rust-related configure items to rust.configure. r=firefox-build-system-reviewers,mhentges
https://hg.mozilla.org/integration/autoland/rev/307e9ac7b22b
Set rust optimization level via CARGO_PROFILE_*_OPT_LEVEL. r=firefox-build-system-reviewers,mhentges
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 90 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: