Opened 11 years ago

Closed 11 years ago

#1994 closed defect (fixed)

"Illegal instruction" when running binaries/system/test on amd64

Reported by: Vincent Cheng Owned by:
Priority: Should Have Milestone: Alpha 15
Component: Build & Packages Keywords:
Cc: Jan Wassenberg, Josh Patch:

Description

Forwarded from Debian's BTS: #712956

0ad fails to build on one of Debian's amd64 build machines, because it errors out when running binaries/system/test ("Illegal instruction"); see build log here. Is it possible that premake (or something else) is injecting certain flags or causing gcc to build 0ad with certain optimizations not universally supported on amd64? I see -msse in the build log, but that should be fine on amd64 (AFAIK amd64 guarantees at least SSE2 support). Could premake be hiding some of the compiler output (even though verbose build is enabled)?

FWIW, the amd64 build machine on which this occurred is barber.debian.org (Dell PowerEdge 1855).

On another note, the i386 build log shows that 0ad is being built with -msse and -march=i686, but that's problematic for Debian given that Debian's "i386" architecture targets i486, not i686. Is it possible for 0ad to be built and run on i486 and without -msse?

Change History (18)

comment:1 by Markus, 11 years ago

Does it also happen in debug build? Can you try running it in gdb? (Unfortunatelly the test file is quite big and the illegal instruction might not show up on a different machine.)

i486 should™ work by modifing the premake4.lua file. (Set arch to i486 and remove sse)

(You can build with make SHELL="/bin/bash -x" ... to see every executed command.)

comment:2 by historic_bruno, 11 years ago

Could it be caused by this bug in NVTT: #1894? The Debian libnvtt package doesn't appear to have a patch applied for that.

About -march=i686, there's a comment in premake4.lua:

-- To support intrinsics like __sync_bool_compare_and_swap on x86
-- we need to set -march to something that supports them

in reply to:  1 comment:3 by Vincent Cheng, 11 years ago

Replying to Markus:

Does it also happen in debug build? Can you try running it in gdb? (Unfortunatelly the test file is quite big and the illegal instruction might not show up on a different machine.)

i486 should™ work by modifing the premake4.lua file. (Set arch to i486 and remove sse)

(You can build with make SHELL="/bin/bash -x" ... to see every executed command.)

It doesn't happen in debug build on my local machine either. Not being able to reproduce this on my own Debian system is definitely making this much harder to debug...

in reply to:  2 ; comment:4 by Vincent Cheng, 11 years ago

Replying to historic_bruno:

Could it be caused by this bug in NVTT: #1894? The Debian libnvtt package doesn't appear to have a patch applied for that.

Ah, that might be the cause. I'll try to get that patch included in Debian's nvtt package, thanks! Incidentally, are there any other patches in 0ad's internal copy of nvtt that should also be applied in Debian?

About -march=i686, there's a comment in premake4.lua:

-- To support intrinsics like __sync_bool_compare_and_swap on x86
-- we need to set -march to something that supports them

Ack, so leave it be and don't force -march=i486.

comment:5 by Vincent Cheng, 11 years ago

Kurt Roeckx made the following comment on Debian bug #712956, which I'll quote here:

Using -march is almost always the wrong thing to do in Debian. This really should only be used if there is an other way to not i686 specific code.

Please note that the function they say they need are now marked as legacy, see http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync http://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html http://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html

Is that comment in premake4.lua still relevant? It looks like it's been in that file since rev 8526, from 3 years back...

Last edited 11 years ago by historic_bruno (previous) (diff)

comment:6 by historic_bruno, 11 years ago

Cc: Jan Wassenberg added

I don't know about alternatives, but we certainly still use __sync_bool_compare_and_swap, see source/lib/sysdep/arch/ia32/ia32.cpp.

CC'ing Jan, he would know all about that code.

comment:7 by Jan Wassenberg, 11 years ago

We wouldn't run on an actual 486 due to use of several newer CPU instructions, one of which is the CAS in ia32.cpp. If indeed we have to compile with -march=i486, which sounds like a last resort, the CAS could be replaced with GCC-specific assembly, and we'd have a decent hope of compiling successfully.

comment:8 by Vincent Cheng, 11 years ago

I see, thanks for the explanation! This is beyond my knowledge, but should at least be sufficient rationale for me not to touch -march in premake4.lua.

in reply to:  4 ; comment:9 by historic_bruno, 11 years ago

Replying to vincent:

Replying to historic_bruno:

Could it be caused by this bug in NVTT: #1894? The Debian libnvtt package doesn't appear to have a patch applied for that.

Ah, that might be the cause. I'll try to get that patch included in Debian's nvtt package, thanks! Incidentally, are there any other patches in 0ad's internal copy of nvtt that should also be applied in Debian?

Don't think so, we keep a list of them in libraries/source/nvtt/README.txt.

(And for reference: #713966 nvidia-texture-tools: OptimalOptions.cmake assumes x86_64 implies athlon64)

Last edited 11 years ago by historic_bruno (previous) (diff)

comment:10 by fabio, 11 years ago

Milestone: BacklogAlpha 14

in reply to:  9 ; comment:11 by fabio, 11 years ago

Replying to historic_bruno:

Replying to vincent:

Incidentally, are there any other patches in 0ad's internal copy of nvtt that should also be applied in Debian?

Don't think so, we keep a list of them in libraries/source/nvtt/README.txt.

The recent arm fix patch will enable to build nvtt on arm. 0ad alpha14 also will build on arm.

in reply to:  11 comment:12 by Vincent Cheng, 11 years ago

Replying to fabio:

The recent arm fix patch will enable to build nvtt on arm. 0ad alpha14 also will build on arm.

May you please link me to the patch that fixes nvtt build on arm? I'd like to have that added to the nvtt packages in Debian and Ubuntu.

comment:13 by fabio, 11 years ago

Cc: Josh added

It's the arm-fix from there: http://trac.wildfiregames.com/browser/ps/trunk/libraries/source/nvtt/patches

Also since the last time I pinged Lennart there is a clang build fix (issue182 patch) and cmake-noqt4 (I think this will disable building with QT4 even when its dev libs are found, to have a consistent build).

Adding Josh in CC, he wrote some of the patches.

Last edited 11 years ago by fabio (previous) (diff)

in reply to:  13 ; comment:14 by Vincent Cheng, 11 years ago

Replying to fabio:

It's the arm-fix from there: http://trac.wildfiregames.com/browser/ps/trunk/libraries/source/nvtt/patches

Also since the last time I pinged Lennart there is a clang build fix (issue182 patch) and cmake-noqt4 (I think this will disable building with QT4 even when its dev libs are found, to have a consistent build).

Adding Josh in CC, he wrote some of the patches.

Thanks! And just to be sure, does this patch enable compilation on armel, armhf, or both? (i.e. soft-float vs hard-float ABI)

in reply to:  14 comment:15 by Josh, 11 years ago

Replying to vincent:

Replying to fabio :

It's the arm-fix from there: http://trac.wildfiregames.com/browser/ps/trunk/libraries/source/nvtt/patches Also since the last time I pinged Lennart there is a clang build fix (issue182 patch) and cmake-noqt4 (I think this will disable building with QT4 even when its dev libs are found, to have a consistent build). Adding Josh in CC, he wrote some of the patches.

Thanks! And just to be sure, does this patch enable compilation on armel, armhf, or both? (i.e. soft-float vs hard-float ABI)

I see no reason why my patch wouldn't work on both platforms, but I've only tested on armhf.

comment:16 by historic_bruno, 11 years ago

Milestone: Alpha 14Alpha 15

comment:17 by fabio, 11 years ago

Debian nvtt since 2.0.8-1+dfsg-4 disable -march=athlon64. Also it successfully builds on arm: http://ftp-master.metadata.debian.org/changelogs//main/n/nvidia-texture-tools/nvidia-texture-tools_2.0.8-1+dfsg-4_changelog

comment:18 by fabio, 11 years ago

Resolution: fixed
Status: newclosed

Fixed in r13806.

Note: See TracTickets for help on using tickets.