protonscr

wine needs -lrt linker option for wine 4.10+

protonclosed
ValveSoftware/Proton#2811 · opened 2019-06-15 by GloriousEggroll · updated 2019-06-24 · 5 comments · github
GGloriousEggroll 2019-06-15 github

More future proofing:

If building with wine 4.10+, the glibc version used in the steam-runtime is too old, resulting in:

: In function `GetTickCount64':
/home/vagrant/build/obj-wine32/dlls/kernel32/../../../../proton/wine/dlls/kernel32/time.c:89: undefined reference to `clock_gettime'
time.o: In function `GetTickCount':
/home/vagrant/build/obj-wine32/dlls/kernel32/../../../../proton/wine/dlls/kernel32/time.c:89: undefined reference to `clock_gettime'
collect2: error: ld returned 1 exit status
winegcc: gcc failed

due to this commit:
https://github.com/wine-mirror/wine/commit/13e11d3fcbcf8790e031c4bc52f5f550b1377b3b#diff-6a2525504a46c037ba422bd9a152239f

this can be resolved by adding -lrt to the LDFLAG options for wine in makefile_base.mak:

LDFLAGS=-L$(abspath $(TOOLS_DIR64))/lib -lrt \

This links in the librt.so "Real Time" shared library. More details can be found here:
https://stackoverflow.com/questions/2418157/c-error-undefined-reference-to-clock-gettime-and-clock-settime

Details regarding glibc:

$ docker run steam-proton-dev ldd --version
ldd (Ubuntu EGLIBC 2.15-0ubuntu10.18+steamrt1.1+srt1) 2.15
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

Since glibc 2.17, the library linking -rt is no longer required.

The clock_* are now part of the main C library. You can see the change history of glibc 2.17 where this change was done explains the reason for this change:

+* The `clock_*' suite of functions (declared in <time.h>) is now available

  • directly in the main C library. Previously it was necessary to link with
  • -lrt to use these functions. This change has the effect that a
  • single-threaded program that uses a function such as `clock_gettime' (and
  • is not linked with -lrt) will no longer implicitly load the pthreads
  • library at runtime and so will not suffer the overheads associated with
  • multi-thread support in other code such as the C++ runtime library.
SSmurf 2019-06-16 github

It should be noted that LDFLAGS must be single quoted for this to work like so:

LDFLAGS='-L$(abspath $(TOOLS_DIR64))/lib -lrt' \

I am also working on getting Proton compiled with Wine 4.10 (thanks for your makefile_base.mak modifications for adding Bison as a submodule!) and ran into this exact issue with both Bison and Wine.

I need Planet Coaster in my life.

Aaeikum 2019-06-18 github

@GloriousEggroll Thanks again for this work. Like the other PR, I'll take a closer look when we do the next Wine merge.

@Smurf In that case, I have very good news for you in the near future...

Aaeikum 2019-06-19 github

This turned out to be an upstream bug. We have logic to add -lrt when needed, but it wasn't being used in kernel32. I've sent a patch to fix this: https://source.winehq.org/patches/data/166854

Edit: This was accepted upstream as d5d43ac9071cf53ca3f6eaa7179f55c6e28c5825, and will be in Wine 4.11.

Aaeikum 2019-06-20 github

@GloriousEggroll Since this is fixed upstream in 4.11+, shall we close this bug?

GGloriousEggroll 2019-06-24 github

@aeikum most def. I've just made a 4.11 build. it seems solid.

Nothing extracted yet.