protonscr

Container updated to support GCC 13 or 14. Container is based on Debian 11 Bullseye, very old.

protonopen Feature Request
ValveSoftware/Proton#8399 · opened 2025-01-19 by roadapathy · updated 2025-02-02 · 5 comments · github
Rroadapathy 2025-01-19 github

Feature Request

More updated Docker container with GCC 14

I confirm:

  • [x] that I haven't found another request for this feature.
  • [x] that I have checked whether there are updates for my system available that
    contain this feature already.

Description

I loaded the container used by the Proton project and did gcc --version to see that it's very old. Version 10! I tried, within the container, to install GCC 14 but there are all sorts of dependencies and things that broke.

Justification [optional]

GCC 14 and above will produce faster code and support newer CPUs and optimizations. I'm trying to compile Proton for my AMD 9950x. I was able to modify the Makefile.in but I don't believe my system GCC, which is the early GCC 15, is being used at any part of the build process because it doesn't recognize -march=znver5 and it almost certainly doesn't work correctly with -march=native. znver3 is the closest that I can get to my own CPU.

Risks [optional]

It breaks everything. GCC 13 and 14 are very stable though and I build the 6.13 Kernel with it. I add -O3 too. Nothing is broken.

References [optional]

Rroadapathy 2025-01-19 github

I don't know how to compile the project outside of the containers. I don't think I could modify it to do this since that's beyond what I know. I just have this really incredible new CPU, the first time I have ever gotten the top desktop CPU in my life, and I'm really hoping to exploit its features using the Proton project.

I will -happily- test the build process using GCC 13, 14, or even 15. Stable 15 is releasing later this year.

Rroadapathy 2025-01-19 github

Dev team, look at all of the optimization goodness that my Proton is missing out on.

gcc -march=znver5 -Q --help=target | grep enabled

-m128bit-long-double [enabled]
-m64 [enabled]
-m80387 [enabled]
-mabm [enabled]
-madx [enabled]
-maes [enabled]
-malign-stringops [enabled]
-mavx [enabled]
-mavx2 [enabled]
-mavx512bf16 [enabled]
-mavx512bitalg [enabled]
-mavx512bw [enabled]
-mavx512cd [enabled]
-mavx512dq [enabled]
-mavx512f [enabled]
-mavx512ifma [enabled]
-mavx512vbmi [enabled]
-mavx512vbmi2 [enabled]
-mavx512vl [enabled]
-mavx512vnni [enabled]
-mavx512vp2intersect [enabled]
-mavx512vpopcntdq [enabled]
-mavxvnni [enabled]
-mbmi [enabled]
-mbmi2 [enabled]
-mclflushopt [enabled]
-mclwb [enabled]
-mclzero [enabled]
-mcrc32 [enabled]
-mcx16 [enabled]
-mdirect-extern-access [enabled]
-mevex512 [enabled]
-mf16c [enabled]
-mfancy-math-387 [enabled]
-mfma [enabled]
-mfp-ret-in-387 [enabled]
-mfsgsbase [enabled]
-mfxsr [enabled]
-mgfni [enabled]
-mglibc [enabled]
-mhard-float [enabled]
-mieee-fp [enabled]
-mlong-double-80 [enabled]
-mlzcnt [enabled]
-mmmx [enabled]
-mmovbe [enabled]
-mmovdir64b [enabled]
-mmovdiri [enabled]
-mmwait [enabled]
-mmwaitx [enabled]
-mpartial-vector-fp-math [enabled]
-mpclmul [enabled]
-mpku [enabled]
-mpopcnt [enabled]
-mprefetchi [enabled]
-mprfchw [enabled]
-mpush-args [enabled]
-mrdpid [enabled]
-mrdrnd [enabled]
-mrdseed [enabled]
-mred-zone [enabled]
-msahf [enabled]
-msha [enabled]
-msse [enabled]
-msse2 [enabled]
-msse3 [enabled]
-msse4 [enabled]
-msse4.1 [enabled]
-msse4.2 [enabled]
-msse4a [enabled]
-mssse3 [enabled]
-mstv [enabled]
-mtls-direct-seg-refs [enabled]
-mvaes [enabled]
-mvpclmulqdq [enabled]
-mwbnoinvd [enabled]
-mxsave [enabled]
-mxsavec [enabled]
-mxsaveopt [enabled]
-mxsaves [enabled]

Rroadapathy 2025-02-01 · hidden on GitHub github

Citing Google Gemini 2.0

I'm compiling Valve Proton for Linux and I'm trying to optimize the code for my AMD 9950x CPU. However, the project uses a container with old GCC 10 so I'm having to force the compiler to use advanced features of my CPU manually. It will only recognize -march=znver3 rather than the znver5 of my CPU. It compiles both 32bit and 64bit code. I tried to optimize in the 32bit code but it breaks the build. Do you see anything here that can be improve?

CROSSLDFLAGS += -Wl,--file-alignment,4096
OPTIMIZE_FLAGS := -O3 -march=nocona -mtune=znver3 -mfpmath=sse -g0 -fomit-frame-pointer
SANITY_FLAGS := -fwrapv -fno-strict-aliasing
DEBUG_FLAGS := -g0 -fomit-frame-pointer
COMMON_FLAGS = $(DEBUG_FLAGS) $(OPTIMIZE_FLAGS) $(SANITY_FLAGS) -ffile-prefix-map=$(CCACHE_BASEDIR)=.
COMMON_FLAGS32 := -mstackrealign -g0 -fomit-frame-pointer
COMMON_FLAGS64 := -mcmodel=small -march=znver3 -mtune=znver3 -g0 -fomit-frame-pointer -mavx512f -mavx512bw -mavx512dq -mavx512vl -mprefer-vector-width=512
CARGO_BUILD_ARGS += --release

"You're on the right track trying to optimize, but there are several things you can improve in your build configuration for Proton, especially given the GCC 10 limitation and your AMD 9950X (Zen 3) CPU.

Key Issues and Improvements:

-march=nocona is Counterproductive: -march=nocona is an old architecture (Core 2 Duo era). You're explicitly telling the compiler to optimize for a very different CPU than yours, completely negating the -mtune=znver3. -march sets the instruction set architecture (ISA), while -mtune provides microarchitecture-specific tuning. You must align -march with your target CPU.

GCC 10 and Zen 3: GCC 10's Zen 3 support is likely not optimal. While -mtune=znver3 helps, the compiler might not fully utilize all the Zen 3 features. Upgrading GCC is the ideal solution, but since you can't, you'll have to work around it.

32-bit Optimization Breaking the Build: This is concerning. It suggests either a compiler bug (more likely with older GCC) or subtle issues in the codebase that aggressive optimizations expose. Focus on getting 64-bit optimized first, then carefully reintroduce optimizations for 32-bit.

-mavx512* Flags with Zen 3: Zen 3 has 256-bit vector units. While it supports some AVX-512 instructions, they are emulated and have a significant performance penalty. Remove all -mavx512* flags. They are hurting, not helping.

-mprefer-vector-width=512: Also remove this. It's related to AVX-512 and will be detrimental.

-mfpmath=sse: Zen 3 supports and prefers FMA instructions. -mfpmath=sse forces the use of SSE, which is slower. Remove this flag. Let the compiler choose the best floating-point instructions.

-mstackrealign (32-bit): This flag is often necessary for older codebases, but it has a performance cost. If you can identify why the 32-bit build needs it, you might be able to fix the underlying alignment issues and remove the flag. If you must keep it, understand it's a performance compromise.

-ffile-prefix-map: This is excellent for reproducible builds and debugging. Keep it.

-g0 -fomit-frame-pointer: These are standard optimization flags for release builds. Keep them (unless you need debugging symbols).

Revised Flags:
Makefile

CROSSLDFLAGS += -Wl,--file-alignment,4096
OPTIMIZE_FLAGS := -O3 -march=znver3 -mtune=znver3 -g0 -fomit-frame-pointer
SANITY_FLAGS := -fwrapv -fno-strict-aliasing
DEBUG_FLAGS := -g0 -fomit-frame-pointer
COMMON_FLAGS = $(DEBUG_FLAGS) $(OPTIMIZE_FLAGS) $(SANITY_FLAGS) -ffile-prefix-map=$(CCACHE_BASEDIR)=.
COMMON_FLAGS32 := -mstackrealign -g0 -fomit-frame-pointer # Investigate removing -mstackrealign
COMMON_FLAGS64 := -mcmodel=small -march=znver3 -mtune=znver3 -g0 -fomit-frame-pointer
CARGO_BUILD_ARGS += --release

Further Steps:

Profile: Use a profiler (like perf) to identify performance bottlenecks. Don't just optimize blindly. Focus on the code that's actually slow.
Incremental Optimization: Reintroduce optimizations gradually, testing thoroughly after each change, especially for the 32-bit build.
Consider LTO (Link-Time Optimization): LTO can often provide significant performance gains. Add -flto to your compiler and linker flags.
Function-Specific Optimizations: If profiling reveals hot spots, you can use function attributes (like __attribute__((target("sse4.2"))) or similar, if appropriate) to fine-tune specific functions. However, use this sparingly and only after careful profiling. Be very careful with this in 32bit code.
Compiler Upgrade (Ideal): The best long-term solution is to upgrade your compiler. Newer GCC or Clang versions will have better Zen 3 support.

By addressing these points, you should see a noticeable improvement in performance. Remember to profile and test thoroughly to ensure stability and measure the actual impact of your changes. The 32-bit issue is a red flag; address it carefully."

Kkisak-valve maintainer 2025-02-01 github

Hello @roadapathy, quoting an AI response to make a project less compatible for the larger user base using the project is both off-topic and non-productive.

Rroadapathy 2025-02-02 github

Hello @roadapathy, quoting an AI response to make a project less compatible for the larger user base using the project is both off-topic and non-productive.

I realize my earlier comment—which quoted an AI suggestion regarding compatibility changes—might have come off as off-topic and unproductive. That wasn’t my intent. I'm not a developer by trade, but I experimented a bit (building Wine with GCC 15) and thought sharing those findings might be helpful.

I care about Proton’s stability and the community’s experience, so if my approach was misguided or if there's a more effective way to contribute, please let me know. I'm more than willing to put in the work—whether that's setting up a container for Proton, testing new versions, or following any guidelines you recommend. I just need a pointer in the right direction.

Thanks for your patience and for all the work you put into the project.

Nothing extracted yet.