Opened 6 years ago

Closed 5 years ago

#5157 closed defect (fixed)

Error when compiling 0ad on Arch & Slackware: stdlib.h: No such file or directory

Reported by: a36233 Owned by: s0600204
Priority: Must Have Milestone: Alpha 24
Component: Build & Packages Keywords:
Cc: Patch: phab:D1582 phab:D1611

Description (last modified by a36233)

==== Building scriptinterface (release) ====
precompiled.h
In file included from ../../../source/lib/sysdep/stl.h:32,
                 from ../../../source/lib/precompiled.h:68,
                 from ../../../source/pch/scriptinterface/precompiled.h:19:
/usr/include/c++/8.1.0/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
 #include_next <stdlib.h>
               ^~~~~~~~~~
compilation terminated.
make[1]: *** [scriptinterface.make:121: obj/scriptinterface_Release/precompiled.h.gch] Error 1
make: *** [Makefile:105: scriptinterface] Error 2

Attachments (5)

mocks_real.make (4.8 KB ) - added by Andy Alt 6 years ago.
scriptinterface.make (6.7 KB ) - added by Andy Alt 6 years ago.
mocks_real_verbose_output_20180813.txt (5.5 KB ) - added by Andy Alt 6 years ago.
0ad.SlackBuild (4.5 KB ) - added by Andy Alt 6 years ago.
working, modded by ponce
slackware_pkgconfig_v1.patch (6.9 KB ) - added by s0600204 6 years ago.
Prospective patch to resolve over-inclusion of contents of /usr/include

Download all attachments as: .zip

Change History (39)

comment:1 by a36233, 6 years ago

Description: modified (diff)

comment:2 by elexis, 6 years ago

wiki:ReportingErrors

I thought it was a bug with gcc 7.3.1, but you are using 8.1.0?

(I still can't reproduce with 7.3.0)

There is a different ticket with the same bug and forum thread.

comment:3 by s0600204, 6 years ago

(Duplicate of #5152. Relevant forum thread.)


What OS are you using?

I don't suppose I could get you to try this:

SDL2_CONFIG="pkg-config sdl2" update-workspaces.sh

then running make?

comment:4 by a36233, 6 years ago

I'm using Arch Linux with gcc version 8.1.0.

$ sh clean-workspaces.sh
$ export SDL2_CONFIG="pkg-config sdl2"
$ sh update-workspaces.sh
$ make

And at least it compiled.

Last edited 6 years ago by a36233 (previous) (diff)

comment:5 by elexis, 6 years ago

andy5995 reported on #0ad-dev today the same error and that it was fixed by running the clean-workspaces.sh script before compiling again.

comment:6 by Andy Alt, 6 years ago

And this is how I was able to reproduce the problem.

With a clean workspace, I ran

./update-workspace.sh --disable-atlas -j5
cd gcc
make -j5

Then:

./update-workspace.sh (with no args)
cd gcc
make -j5

The second build fails.

The error is actually different from the one posted above

Linking ActorEditor
==== Building cxxtestroot (release) ====
Generating test root file
/home/andy/src/0ad_svn/libraries/source/cxxtest-4.4/bin/cxxtestgen --root  --include=precompiled.h --include=lib/external_libraries/libsdl.h --runner=ErrorPrinter -o /home/andy/src/0ad_svn/source/test_root.cpp
==== Building test (release) ====
Generating test_AtlasObjectXML.cpp
test_root.cpp
cc1plus: error: one or more PCH files were found, but they were invalid
cc1plus: error: use -Winvalid-pch for more information
cc1plus: fatal error: obj/test_Release/precompiled.h: No such file or directory
compilation terminated.
test.make:1600: recipe for target 'obj/test_Release/test_root.o' failed
make[1]: *** [obj/test_Release/test_root.o] Error 1
make[1]: *** Waiting for unfinished jobs....
Makefile:188: recipe for target 'test' failed
make: *** [test] Error 2

I'm on Debian 9 with g++ 6.3

I assume omitting the -j5 isn't relevant, but omitting the --disable-atlas is.

Last edited 6 years ago by Andy Alt (previous) (diff)

comment:7 by Stan, 6 years ago

Owner: set to Andreas Nilsson

comment:8 by Andy Alt, 6 years ago

In the case I mentioned above, I have since found that cleaning isn't necessary if the build fails. I can just re-run update-workspaces.sh with the same options as I did before (i.e. --disable atlas in that case) and then run make again.

Last edited 6 years ago by Andy Alt (previous) (diff)

comment:9 by elexis, 6 years ago

Milestone: Alpha 24Alpha 23

Reminder to test if --disable-atlas is actually broken and fixable.

comment:10 by elexis, 6 years ago

Milestone: Alpha 23Alpha 24

Hm, I could compile without-atlas and confirm that atlas isn'T part of the binary. Not sure what's going on here then.

comment:11 by elexis, 6 years ago

Component: UI & SimulationCore engine
Milestone: Alpha 24

After successfully building with --disable-atlas, then running update-workspaces.sh again (without the argument) and make again, I got the error. After running clean-workspaces.sh the error went away. So this is likely a non-issue.

We should try this for the new release candidates, see also this guy who reported this issue for a release candidate #5152.

comment:12 by elexis, 6 years ago

Owner: Andreas Nilsson removed

comment:13 by elexis, 6 years ago

Resolution: needsinfo
Status: newclosed

Has to be reopened if we know a reliable way to reproduce errors without user mistake.

If it can be reproduced, one could find the offending revision by testing specific commits (maybe it was r21789, r21788, r21759 or an atlas commit?), otherwise with binary search up to r18916.

comment:14 by s0600204, 6 years ago

Component: Core engineBuild & Packages
Milestone: Backlog
Resolution: needsinfo
Status: closedreopened

It has been observed that setting the environment variable SDL2_CONFIG to pkg-config sdl2 prior to running update-workspaces.sh clears the originally reported problem. It is what I suggested above, confirmed as working by the Original Poster, and it is the solution used by the maintainer of the official Arch package repos.

Instead of getting tangled up with the --disable-atlas argument (which is... most likely a completely different issue to the one originally reported and thus warrants its own ticket without hijacking this one) let's look into this.

Without the environment argument being set, when the SDL2 libraries are included, then the following command is run to fetch the determine the library dependencies: sdl2-config --cflags. On Arch Linux with gcc 8.1.0, this command returns the following:

-I/usr/include/SDL2 -I/usr/include -D_REENTRANT

With the environment variable set, we instead end up running pkg-config sdl2 --cflags to determine the library dependencies of SDL2. This results in the following output:

-D_REENTRANT -I/usr/include/SDL2.

And here's the entire line used when compiling the file precompiled.h in module scriptinterface (the first file to fail compiling as reported above), first without the environment argument set:

g++ -x c++-header -MMD -MP -DNDEBUG -DCONFIG_FINAL=1 -DLIB_STATIC_LINK -DUSING_PCH -I../../../source/pch/scriptinterface -I../../../source -isystem ../../../libraries/source/spidermonkey/include-unix-release -isystem ../../../libraries/source/valgrind/include -isystem /usr/include/SDL2 -isystem /usr/include -isystem /usr/X11R6/include/X11 -isystem /usr/X11R6/include -isystem /usr/local/include/X11 -isystem /usr/local/include -isystem /usr/include/X11 -O3 -g -Wall -Wextra -Wno-switch -Wno-reorder -Wno-invalid-offsetof -Wextra -Wno-missing-field-initializers -Wunused-parameter -Wredundant-decls -Wnon-virtual-dtor -Wundef -fstack-protector-all -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstrict-aliasing -fno-omit-frame-pointer -fpch-preprocess -fPIC -std=c++0x -fvisibility=hidden -D_REENTRANT -o "obj/scriptinterface_Release/precompiled.h.gch" -MF "obj/scriptinterface_Release/precompiled.h.d" -c "../../../source/pch/scriptinterface/precompiled.h"

...and now with it:

g++ -x c++-header -MMD -MP -DNDEBUG -DCONFIG_FINAL=1 -DLIB_STATIC_LINK -DUSING_PCH -I../../../source/pch/scriptinterface -I../../../source -isystem ../../../libraries/source/spidermonkey/include-unix-release -isystem ../../../libraries/source/valgrind/include -isystem /usr/include/SDL2 -isystem /usr/X11R6/include/X11 -isystem /usr/X11R6/include -isystem /usr/local/include/X11 -isystem /usr/local/include -isystem /usr/include/X11 -O3 -g -Wall -Wextra -Wno-switch -Wno-reorder -Wno-invalid-offsetof -Wextra -Wno-missing-field-initializers -Wunused-parameter -Wredundant-decls -Wnon-virtual-dtor -Wundef -fstack-protector-all -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstrict-aliasing -fno-omit-frame-pointer -fpch-preprocess -fPIC -std=c++0x -fvisibility=hidden -D_REENTRANT -o "obj/scriptinterface_Release/precompiled.h.gch" -MF "obj/scriptinterface_Release/precompiled.h.d" -c "../../../source/pch/scriptinterface/precompiled.h"

The only difference in both cases is that /usr/include is not included in the second of each set.

So, questions:

  1. Why does not including /usr/include permit compilation to work? (I suspect it has something to do with gcc's #include_next macro.)
  2. What do sdl2-config --cflags and pkg-config sdl2 --cflags return on other linux distros?
  3. How about the includes for scriptinterface?

(Apologies if the answer to 1 seems obvious to some, I'm not that familiar with compilation/linking, so... educate me.)

comment:15 by Stan, 6 years ago

Owner: set to Andreas Nilsson
Status: reopenednew

Bug was reported by ani here: https://bugs.archlinux.org/task/58859

comment:16 by Stan, 6 years ago

Milestone: BacklogWork In Progress

comment:17 by s0600204, 6 years ago

Owner: changed from Andreas Nilsson to s0600204
Patch: phab:D1582
Status: newassigned

Further links, for quick access:

comment:18 by elexis, 6 years ago

Milestone: Work In ProgressAlpha 23
Priority: Release BlockerMust Have

I guess this should be fixed on our side for the upcoming releae. Not sure if others agree that it's a RB, but certainly high priority and high urgency.

comment:19 by elexis, 6 years ago

Summary: Error when compiling 0adError when compiling 0ad on Arch: stdlib.h: No such file or directory

comment:20 by Stan, 6 years ago

I agree it's one. Anything we can fix ( As in we have a patch for) that is likely to create dozens of false positives or non obvious tickets should be fixed IMHo. Not to mention that since we are forcing package mainteners to recompile we could at least make their lives easier.

comment:21 by Andy Alt, 6 years ago

On Slackware 64-current which comes with g++ 8.2.0.

I got the same error but it first happened when building "mocks_real".

I tested phab:D1582 but got the same result.

Generated ../workspaces/gcc/Collada.make...
Generated ../workspaces/gcc/cxxtestroot.make...
Generated ../workspaces/gcc/test.make...
Done (581ms).
==== Building mocks_real (release) ====
mocks_real.cpp
In file included from ../../../source/lib/sysdep/stl.h:32,
                 from ../../../source/lib/precompiled.h:68,
                 from ../../../source/mocks/mocks_real.cpp:26:
/usr/include/c++/8.2.0/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
 #include_next <stdlib.h>
               ^~~~~~~~~~
compilation terminated.
make[1]: *** [mocks_real.make:123: obj/mocks_real_Release/mocks_real.o] Error 1
make: *** [Makefile:141: mocks_real] Error 2

andy@demeter:~/src/0ad/trunk/build/workspaces/gcc$ make scriptinterface
==== Building scriptinterface (release) ====
precompiled.h
In file included from ../../../source/lib/sysdep/stl.h:32,
                 from ../../../source/lib/precompiled.h:68,
                 from ../../../source/pch/scriptinterface/precompiled.h:19:
/usr/include/c++/8.2.0/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
 #include_next <stdlib.h>
               ^~~~~~~~~~
compilation terminated.
make[1]: *** [scriptinterface.make:121: obj/scriptinterface_Release/precompiled.h.gch] Error 1
make: *** [Makefile:99: scriptinterface] Error 2

comment:22 by s0600204, 6 years ago

Hi Andy, sorry to hear you're having problems.

Just to cover the obvious, are you calling make clean before compiling?

And how have you been handing the different Slackware versions? Are you using different physical/virtual machines, or do you have all the libraries installed under one system?

I'm assuming that what you've written in #4789 is up-to-date.

With the patch applied, and update-workspaces.sh run, would you mind uploading the generated mocks_real.make and scripinterface.make files from ./workspaces/gcc/ please? I'd like to see how they differ from mine.

And finally, what are the outputs of the following commands?:

pkg-config sdl2 --cflags
cpp -v /dev/null -o /dev/null

Heh, gcc 5.3 to 8.2. That's quite a jump.

Last edited 6 years ago by s0600204 (previous) (diff)

comment:23 by Andy Alt, 6 years ago

Just to cover the obvious, are you calling make clean before compiling?

After I applied the patch, I ran clean-workspaces.sh and then update-workspaces.sh --disable-atlas -j5 && cd gcc && make -j5

Are you using different physical/virtual machines, or do you have all the libraries installed under one system?

3 logical partitions, Slack 14.2-(32,64), and 64-current

I'm assuming that what you've written in #4789 is up-to-date.

Yes, that ticket and the new build instructions I added only pertain to 14.2.

I'll attach the 2 files you mentioned.

$ pkg-config sdl2 --cflags
-D_REENTRANT -I/usr/include/SDL2
$ cpp -v /dev/null -o /dev/null
Reading specs from /usr/lib64/gcc/x86_64-slackware-linux/8.2.0/specs
COLLECT_GCC=cpp
Target: x86_64-slackware-linux
Configured with: ../gcc-8.2.0/configure --prefix=/usr --libdir=/usr/lib64 --mandir=/usr/man --infodir=/usr/info --enable-shared --enable-bootstrap --enable-languages=ada,brig,c,c++,fortran,go,lto,objc --enable-threads=posix --enable-checking=release --enable-objc-gc --with-system-zlib --enable-libstdcxx-dual-abi --with-default-libstdcxx-abi=new --disable-libstdcxx-pch --disable-libunwind-exceptions --enable-__cxa_atexit --disable-libssp --enable-gnu-unique-object --enable-plugin --enable-lto --disable-install-libiberty --disable-werror --with-gnu-ld --verbose --with-arch-directory=amd64 --disable-gtktest --disable-multilib --target=x86_64-slackware-linux --build=x86_64-slackware-linux --host=x86_64-slackware-linux
Thread model: posix
gcc version 8.2.0 (GCC) 
COLLECT_GCC_OPTIONS='-E' '-v' '-o' '/dev/null' '-mtune=generic' '-march=x86-64'
 /usr/libexec/gcc/x86_64-slackware-linux/8.2.0/cc1 -E -quiet -v /dev/null -o /dev/null -mtune=generic -march=x86-64
ignoring nonexistent directory "/usr/lib64/gcc/x86_64-slackware-linux/8.2.0/../../../../x86_64-slackware-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib64/gcc/x86_64-slackware-linux/8.2.0/include
 /usr/local/include
 /usr/lib64/gcc/x86_64-slackware-linux/8.2.0/include-fixed
 /usr/include
End of search list.
COMPILER_PATH=/usr/libexec/gcc/x86_64-slackware-linux/8.2.0/:/usr/libexec/gcc/x86_64-slackware-linux/8.2.0/:/usr/libexec/gcc/x86_64-slackware-linux/:/usr/lib64/gcc/x86_64-slackware-linux/8.2.0/:/usr/lib64/gcc/x86_64-slackware-linux/:/usr/lib64/gcc/x86_64-slackware-linux/8.2.0/../../../../x86_64-slackware-linux/bin/
LIBRARY_PATH=/usr/lib64/gcc/x86_64-slackware-linux/8.2.0/:/usr/lib64/gcc/x86_64-slackware-linux/8.2.0/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib64/gcc/x86_64-slackware-linux/8.2.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-E' '-v' '-o' '/dev/null' '-mtune=generic' '-march=x86-64'

Heh, gcc 5.3 to 8.2. That's quite a jump.

Yeah. And the gcc version could change yet (and maybe decrease again) before Slack 15.0 is released. -current is pretty unstable.

by Andy Alt, 6 years ago

Attachment: mocks_real.make added

by Andy Alt, 6 years ago

Attachment: scriptinterface.make added

comment:24 by Andy Alt, 6 years ago

I tried making 3 other targets: lobby, engine, and gui. None of them can find stdlib.h. Would you like those attached as well?

comment:26 by s0600204, 6 years ago

Thanks, Andy.

Would you like those attached as well?

No, I just wanted to see one that included the SDL2 header files (scriptinterface) and one that doesn't (mocks_real). They're textually identical to what I get, so that's good.

The output from pkg-config and the cpp [...] thing is close enough to what I get (obviously on my system it doesn't refer to slackware) so that's okay.

Hmm...

Do you have anything installed under /usr/local/include? (ie. is it an empty folder and if not, what is present?)

Also, would you mind opening up mocks_real.make and making a couple of small additions? If you could add a hash (#) to the start of line 8 (which comments the line out). Then add -v to the end of line 23 (which will make the build verbose).

Then re-run make mocks_real. You'll get a fair bit of output... but if you could copy-paste it to a text-file and upload it here. (Based on what you've provided so far I don't expect any anomalies, but I just want to make sure.)

comment:27 by Andy Alt, 6 years ago

Do you have anything installed under /usr/local/include? (ie. is it an empty folder and if not, what is present?)

/usr/local/include is an empty folder.

comment:28 by Andy Alt, 6 years ago

Thanks to ponce we can now build and RUN 0 A.D. on Slackware64-current.

ponce wrote:

this testing script for 0.0.23, beside not being extremely clean, works on current

http://ponce.cc/slackware/testing/0ad-data/

http://ponce.cc/slackware/testing/0ad/

I was inspired by a bug report and decided to change all the -isystem >with -I and make the build system point to proper headers.

on stable it still segfaults :/

I'm going to attach the Slackbuild script so we have it stored locally. We probably won't use the script as it is, because it's intended for release packages, but it shows the modifications made.

by Andy Alt, 6 years ago

Attachment: 0ad.SlackBuild added

working, modded by ponce

by s0600204, 6 years ago

Prospective patch to resolve over-inclusion of contents of /usr/include

comment:29 by s0600204, 6 years ago

Yeah, hmm... no. We include system headers with -isystem for a reason. I mean, they're system headers - they kinda need to be included with -isystem.

Trying (and I do mean "trying") to include them with -I causes gcc to complain that you're trying to include

a non-system directory that duplicates a system directory

and to then ignore the attempt. Of course we don't see the complaint because we tell gcc to be silent.

Also, the approach given in the file uses a scattergun approach which will cause problems in the future.

Anyway...

Andy, could I ask you to try my attached patch? (Revert back to base state (so the phab:D1582 patch is not applied), apply the attached patch, then recompile (but not using ponce's approach).)


Also, why is /usr/lib64/qt/include being included in the search path in the verbose compile log of mocks_real? We don't use Qt at all, nor do any of our dependancies, yet according to that output it's being added to the includes search path twice.

in reply to:  29 ; comment:30 by Andy Alt, 6 years ago

Replying to s0600204:

Andy, could I ask you to try my attached patch? (Revert back to base state (so the phab:D1582 patch is not applied), apply the attached patch, then recompile (but not using ponce's approach).)

Yeah, your patch works. Nice!


Also, why is /usr/lib64/qt/include being included in the search path in the verbose compile log of mocks_real? We don't use Qt at all, nor do any of our dependancies, yet according to that output it's being added to the includes search path twice.

Good question. I asked about it an LQ thread. The short answer:

$ set | grep qt
CPLUS_INCLUDE_PATH=/usr/lib64/qt/include:/usr/lib64/qt/include

But why it's being set like that is a mystery and maybe needs to be looked at before Patrick changes current to 15.0.

in reply to:  30 comment:31 by s0600204, 6 years ago

Patch: phab:D1582phab:D1582 phab:D1611
Summary: Error when compiling 0ad on Arch: stdlib.h: No such file or directoryError when compiling 0ad on Arch & Slackware: stdlib.h: No such file or directory

Replying to Andy A.:

Yeah, your patch works. Nice!

Excellent.

As this goes a little beyond the established scope of phab:D1582, I've uploaded it to a new revision: phab:D1611 (which depends on D1582). The patch at this new revision is a bit more extensive but contains the same basic logic changes as the above patch.


Also, why is /usr/lib64/qt/include being included [...]?

CPLUS_INCLUDE_PATH=/usr/lib64/qt/include:/usr/lib64/qt/include

Huh. That'd do it. Thanks!

comment:32 by s0600204, 6 years ago

In 21865:

Use pkg-config instead of sdl2-config

Resolves build issue on Arch Linux (and Arch-derivatives)

(Also forms part of a fix for Slackware-current builds)

Accepted By: echotangoecho (Arch)
Confirmed as functional by: Imarok (Ubuntu 16.04, gcc5.4), wes-fole-dog (Parabola)
Refs: #5157
Fixes: #5152
Differential Revision: https://code.wildfiregames.com/D1582

comment:33 by Itms, 5 years ago

Milestone: Alpha 23Alpha 24

This was mostly fixed, but leaving this ticket open until we include a larger-scope solution in A24 with Phab:D1611. This should happen very early in the development cycle.

comment:34 by s0600204, 5 years ago

Resolution: fixed
Status: assignedclosed

In 22302:

Use pkg-config where possible instead of hard-coding or library-specific programs

Accepted by: Itms, wraitii
Previously tested by: andy5995
Fixes: #5157
Refs: D1582
Differential Revision: https://code.wildfiregames.com/D1611

Note: See TracTickets for help on using tickets.