mickael9 / ioq3

This is an up-to-date fork of ioquake3 for UrbanTerror with changes from the ioUrbanTerror engine
GNU General Public License v2.0
42 stars 18 forks source link

No connection to server when compiled with '-fstrict-aliasing' #40

Closed holgersson32644 closed 2 years ago

holgersson32644 commented 2 years ago

Hi, I need to disable strict-aliasing while compiling. Otherwise urbanterror compiles and starts properly, but I'm not able to connect to any server.

I'm running Gentoo/Linux with gcc-11.2.1:

% gcc -march=native -E -v - </dev/null 2>&1 | grep cc1
 /usr/libexec/gcc/x86_64-pc-linux-gnu/11.2.1/cc1 -E -quiet -v - -march=znver2 -mmmx -mpopcnt -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mavx -mavx2 -msse4a -mno-fma4 -mno-xop -mfma -mno-avx512f -mbmi -mbmi2 -maes -mpclmul -mno-avx512vl -mno-avx512bw -mno-avx512dq -mno-avx512cd -mno-avx512er -mno-avx512pf -mno-avx512vbmi -mno-avx512ifma -mno-avx5124vnniw -mno-avx5124fmaps -mno-avx512vpopcntdq -mno-avx512vbmi2 -mno-gfni -mno-vpclmulqdq -mno-avx512vnni -mno-avx512bitalg -mno-avx512bf16 -mno-avx512vp2intersect -mno-3dnow -madx -mabm -mno-cldemote -mclflushopt -mclwb -mclzero -mcx16 -mno-enqcmd -mf16c -mfsgsbase -mfxsr -mno-hle -msahf -mno-lwp -mlzcnt -mmovbe -mno-movdir64b -mno-movdiri -mmwaitx -mno-pconfig -mno-pku -mno-prefetchwt1 -mprfchw -mno-ptwrite -mrdpid -mrdrnd -mrdseed -mno-rtm -mno-serialize -mno-sgx -msha -mno-shstk -mno-tbm -mno-tsxldtrk -mno-vaes -mno-waitpkg -mwbnoinvd -mxsave -mxsavec -mxsaveopt -mxsaves -mno-amx-tile -mno-amx-int8 -mno-amx-bf16 -mno-uintr -mno-hreset -mno-kl -mno-widekl -mno-avxvnni --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=512 -mtune=znver2 -dumpbase -
mickael9 commented 2 years ago

Hi,

I don't think you can just enable -fstrict-aliasing and expect it to work. The option allows the compiler to assume that strict aliasing rules are respected in the code, which is certainly not the case.

Why would you need it anyway?

Flowdalic commented 2 years ago

Hi @mickael9, thanks for your reply. :)

Note that this is about explicitly disabling strict aliasing, not enabling it. Strict aliasing is enabled per default on GCC if -O2 is used. Since it appears that ioq3 requires strict aliasing to be disabled, it should explicitly do so in its build system to override the compiler's default.

Flowdalic commented 2 years ago

I just discovered that strict aliasing is already explicitly disabled https://github.com/mickael9/ioq3/blob/c988f7669bd70b59beb384563d4c8304062ae011/Makefile#L321. @holgersson32644 could it be that you ran into this on a system which had it explicitly re-enabled?

holgersson32644 commented 2 years ago

@mickael9 @Flowdalic Indeed, my mistake! GCC enables it with -O2 and it's already masked in the Makefile — which we patch in Gentoo to allow using custom CFLAGS (and others). I'm not sure why it didn't hit me earlier though, but it's definetly not a new regression in ioq3.