Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre-compiled headers does not allow to compile the game properly #42598

Closed
nikow opened this issue Jul 31, 2020 · 11 comments
Closed

Pre-compiled headers does not allow to compile the game properly #42598

nikow opened this issue Jul 31, 2020 · 11 comments
Labels
Code: Build Issues regarding different builds and build environments stale Closed for lack of activity, but still valid.

Comments

@nikow
Copy link
Contributor

nikow commented Jul 31, 2020

I always build the game using command:
make -j$(nproc) NATIVE=linux64 CCACHE=1 RELEASE=1 LTO=1 TILES=1 SOUND=1 CLANG=1 BACKTRACE=0 RUNTESTS=0` When i was on commit 5c118cddba6c2d8effbc2420851b70bc1c6a7587 everything was fine, but on commit 36d06eb1f6a31111b5f5b37d83414c2f2d7a557d i am getting errors like that: `[nikow@thinira Cataclysm-DDA]$ make -j$(nproc) NATIVE=linux64 CCACHE=1 RELEASE=1 LTO=1 TILES=1 SOUND=1 CLANG=1 BACKTRACE=0 RUNTESTS=0 astyle -V: Artistic Style Version 3.1 find data -name "*.json" -print0 | grep -v -z -F -f json_blacklist | \ xargs -0 -L 1 tools/format/json_formatter.cgi no astyle regressions CCACHE_CPP2=1 CCACHE_SLOPPINESS=pch_defines,time_macros ccache clang++ -DRELEASE -DGIT_VERSION -DTILES -DLOCALIZE -ffast-math -O3 -flto -Xclang -fno-pch-timestamp -Werror -Wall -Wextra -Wformat-signedness -Wlogical-op -Wmissing-declarations -Wmissing-noreturn -Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual -Wpedantic -Wsuggest-override -Wunused-macros -Wzero-as-null-pointer-constant -Wno-unknown-warning-option -Wredundant-decls -fsigned-char -std=c++14 -MMD -MP -m64 -I/usr/include/SDL2 -D_REENTRANT -DSDL_SOUND -I/usr/include/SDL2 -D_REENTRANT -I/usr/include/SDL2 -D_REENTRANT -I/usr/include/SDL2 -D_REENTRANT -Ipch -Winvalid-pch -include-pch pch/pch.hpp.pch -c src/activity_actor.cpp -o obj/tiles/activity_actor.o CCACHE_CPP2=1 CCACHE_SLOPPINESS=pch_defines,time_macros ccache clang++ -DRELEASE -DGIT_VERSION -DTILES -DLOCALIZE -ffast-math -O3 -flto -Xclang -fno-pch-timestamp -Werror -Wall -Wextra -Wformat-signedness -Wlogical-op -Wmissing-declarations -Wmissing-noreturn -Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual -Wpedantic -Wsuggest-override -Wunused-macros -Wzero-as-null-pointer-constant -Wno-unknown-warning-option -Wredundant-decls -fsigned-char -std=c++14 -MMD -MP -m64 -I/usr/include/SDL2 -D_REENTRANT -DSDL_SOUND -I/usr/include/SDL2 -D_REENTRANT -I/usr/include/SDL2 -D_REENTRANT -I/usr/include/SDL2 -D_REENTRANT -Ipch -Winvalid-pch -include-pch pch/pch.hpp.pch -c src/activity_handlers.cpp -o obj/tiles/activity_handlers.o CCACHE_CPP2=1 CCACHE_SLOPPINESS=pch_defines,time_macros ccache clang++ -DRELEASE -DGIT_VERSION -DTILES -DLOCALIZE -ffast-math -O3 -flto -Xclang -fno-pch-timestamp -Werror -Wall -Wextra -Wformat-signedness -Wlogical-op -Wmissing-declarations -Wmissing-noreturn -Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual -Wpedantic -Wsuggest-override -Wunused-macros -Wzero-as-null-pointer-constant -Wno-unknown-warning-option -Wredundant-decls -fsigned-char -std=c++14 -MMD -MP -m64 -I/usr/include/SDL2 -D_REENTRANT -DSDL_SOUND -I/usr/include/SDL2 -D_REENTRANT -I/usr/include/SDL2 -D_REENTRANT -I/usr/include/SDL2 -D_REENTRANT -Ipch -Winvalid-pch -include-pch pch/pch.hpp.pch -c src/activity_item_handling.cpp -o obj/tiles/activity_item_handling.o CCACHE_CPP2=1 CCACHE_SLOPPINESS=pch_defines,time_macros ccache clang++ -DRELEASE -DGIT_VERSION -DTILES -DLOCALIZE -ffast-math -O3 -flto -Xclang -fno-pch-timestamp -Werror -Wall -Wextra -Wformat-signedness -Wlogical-op -Wmissing-declarations -Wmissing-noreturn -Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual -Wpedantic -Wsuggest-override -Wunused-macros -Wzero-as-null-pointer-constant -Wno-unknown-warning-option -Wredundant-decls -fsigned-char -std=c++14 -MMD -MP -m64 -I/usr/include/SDL2 -D_REENTRANT -DSDL_SOUND -I/usr/include/SDL2 -D_REENTRANT -I/usr/include/SDL2 -D_REENTRANT -I/usr/include/SDL2 -D_REENTRANT -Ipch -Winvalid-pch -include-pch pch/pch.hpp.pch -c src/advanced_inv.cpp -o obj/tiles/advanced_inv.o CCACHE_CPP2=1 CCACHE_SLOPPINESS=pch_defines,time_macros ccache clang++ -DRELEASE -DGIT_VERSION -DTILES -DLOCALIZE -ffast-math -O3 -flto -Xclang -fno-pch-timestamp -Werror -Wall -Wextra -Wformat-signedness -Wlogical-op -Wmissing-declarations -Wmissing-noreturn -Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual -Wpedantic -Wsuggest-override -Wunused-macros -Wzero-as-null-pointer-constant -Wno-unknown-warning-option -Wredundant-decls -fsigned-char -std=c++14 -MMD -MP -m64 -I/usr/include/SDL2 -D_REENTRANT -DSDL_SOUND -I/usr/include/SDL2 -D_REENTRANT -I/usr/include/SDL2 -D_REENTRANT -I/usr/include/SDL2 -D_REENTRANT -Ipch -Winvalid-pch -include-pch pch/pch.hpp.pch -c src/advanced_inv_area.cpp -o obj/tiles/advanced_inv_area.o CCACHE_CPP2=1 CCACHE_SLOPPINESS=pch_defines,time_macros ccache clang++ -DRELEASE -DGIT_VERSION -DTILES -DLOCALIZE -ffast-math -O3 -flto -Xclang -fno-pch-timestamp -Werror -Wall -Wextra -Wformat-signedness -Wlogical-op -Wmissing-declarations -Wmissing-noreturn -Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual -Wpedantic -Wsuggest-override -Wunused-macros -Wzero-as-null-pointer-constant -Wno-unknown-warning-option -Wredundant-decls -fsigned-char -std=c++14 -MMD -MP -m64 -I/usr/include/SDL2 -D_REENTRANT -DSDL_SOUND -I/usr/include/SDL2 -D_REENTRANT -I/usr/include/SDL2 -D_REENTRANT -I/usr/include/SDL2 -D_REENTRANT -Ipch -Winvalid-pch -include-pch pch/pch.hpp.pch -c src/advanced_inv_pane.cpp -o obj/tiles/advanced_inv_pane.o CCACHE_CPP2=1 CCACHE_SLOPPINESS=pch_defines,time_macros ccache clang++ -DRELEASE -DGIT_VERSION -DTILES -DLOCALIZE -ffast-math -O3 -flto -Xclang -fno-pch-timestamp -Werror -Wall -Wextra -Wformat-signedness -Wlogical-op -Wmissing-declarations -Wmissing-noreturn -Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual -Wpedantic -Wsuggest-override -Wunused-macros -Wzero-as-null-pointer-constant -Wno-unknown-warning-option -Wredundant-decls -fsigned-char -std=c++14 -MMD -MP -m64 -I/usr/include/SDL2 -D_REENTRANT -DSDL_SOUND -I/usr/include/SDL2 -D_REENTRANT -I/usr/include/SDL2 -D_REENTRANT -I/usr/include/SDL2 -D_REENTRANT -Ipch -Winvalid-pch -include-pch pch/pch.hpp.pch -c src/ammo.cpp -o obj/tiles/ammo.o <built-in>:1:9: error: macro is not used [-Werror,-Wunused-macros] #define TILES 1 ^ <built-in>:2:9: error: macro is not used [-Werror,-Wunused-macros] #define _REENTRANT 1 ^ <built-in>:3:9: error: macro is not used [-Werror,-Wunused-macros] #define SDL_SOUND 1 ^ 3 errors generated. make: *** [Makefile:912: obj/tiles/ammo.o] Błąd 1 make: *** Oczekiwanie na niezakończone zadania.... <built-in>:1:9: error: macro is not used [-Werror,-Wunused-macros] #define TILES 1 ^ <built-in>:2:9: error: macro is not used [-Werror,-Wunused-macros] #define _REENTRANT 1 ^ <built-in>:3:9: error: macro is not used [-Werror,-Wunused-macros] #define SDL_SOUND 1 ^ 3 errors generated. make: *** [Makefile:912: obj/tiles/advanced_inv_pane.o] Błąd 1 <built-in>:1:9: error: macro is not used [-Werror,-Wunused-macros] #define TILES 1 ^ <built-in>:2:9: error: macro is not used [-Werror,-Wunused-macros] #define _REENTRANT 1 ^ <built-in>:3:9: error: macro is not used [-Werror,-Wunused-macros] #define SDL_SOUND 1 ^ 3 errors generated. make: *** [Makefile:912: obj/tiles/advanced_inv_area.o] Błąd 1 <built-in>:1:9: error: macro is not used [-Werror,-Wunused-macros] #define TILES 1 ^ <built-in>:2:9: error: macro is not used [-Werror,-Wunused-macros] #define _REENTRANT 1 ^ <built-in>:3:9: error: macro is not used [-Werror,-Wunused-macros] #define SDL_SOUND 1 ^ 3 errors generated. make: *** [Makefile:912: obj/tiles/advanced_inv.o] Błąd 1 <built-in>:1:9: error: macro is not used [-Werror,-Wunused-macros] #define TILES 1 ^ <built-in>:2:9: error: macro is not used [-Werror,-Wunused-macros] #define _REENTRANT 1 ^ <built-in>:3:9: error: macro is not used [-Werror,-Wunused-macros] #define SDL_SOUND 1 ^ 3 errors generated. make: *** [Makefile:912: obj/tiles/activity_actor.o] Błąd 1 <built-in>:1:9: error: macro is not used [-Werror,-Wunused-macros] #define TILES 1 ^ <built-in>:2:9: error: macro is not used [-Werror,-Wunused-macros] #define _REENTRANT 1 ^ <built-in>:3:9: error: macro is not used [-Werror,-Wunused-macros] #define SDL_SOUND 1 ^ 3 errors generated. make: *** [Makefile:912: obj/tiles/activity_item_handling.o] Błąd 1 <built-in>:1:9: error: macro is not used [-Werror,-Wunused-macros] #define TILES 1 ^ <built-in>:2:9: error: macro is not used [-Werror,-Wunused-macros] #define _REENTRANT 1 ^ <built-in>:3:9: error: macro is not used [-Werror,-Wunused-macros] #define SDL_SOUND 1 ^ 3 errors generated. make: *** [Makefile:912: obj/tiles/activity_handlers.o] Błąd 1

Steps To Reproduce

  1. Clone fresh repo.
  2. git checkout 5c118cddba6c2d8effbc2420851b70bc1c6a7587
  3. Autogen and call ./configure
  4. Compile text version with make -j$(nproc) NATIVE=linux64 CCACHE=1 RELEASE=1 LTO=1 CLANG=1 BACKTRACE=0 RUNTESTS=0
  5. Compile tiles version with make -j$(nproc) NATIVE=linux64 CCACHE=1 RELEASE=1 LTO=1 TILES=1 SOUND=1 CLANG=1 BACKTRACE=0 RUNTESTS=0
  6. git checkout 36d06eb1f6a31111b5f5b37d83414c2f2d7a557d
  7. Call again compile command make -j$(nproc) NATIVE=linux64 CCACHE=1 RELEASE=1 LTO=1 TILES=1 SOUND=1 CLANG=1 BACKTRACE=0 RUNTESTS=0
  8. Errors are on the console

Expected behavior

Game compiles and creates playable executable.

Versions and configuration

  • OS: Fedora release 31 (Thirty One)
  • Game Version: Commit 36d06eb
  • Graphics version: Both
  • Ingame language: English, but my locales are Polish
  • Mods loaded: [e.g.dda, boats, hacktheplanet, StatsThroughSkills]

Additional context

There is workaround provided by @anothersimulacrum, flag PCH=0 solves issue.

@nikow nikow changed the title Pre-compiled headers Pre-compiled headers does not allow to compile the game properly Jul 31, 2020
@andrei8l
Copy link
Contributor

andrei8l commented Jul 31, 2020

Looks like your clang complains about -DTILES, -DSDL_SOUND, etc which don't affect the pch at all. Pretty confusing...
What's your clang version? I don't get the errors with 10.0.1

(also use ``` when quoting multi-line text to preserve line breaks)

@andrei8l
Copy link
Contributor

Wait a minute what's this bit here
Autogen and call ./configure
That's not part of the build process. Doesn't that alter the makefile?

@gileri
Copy link
Contributor

gileri commented Aug 2, 2020

The same problem is also triggered by the Archlinux AUR build script, or simply the following commands :

make clean && make TILES=1 && make TILES=0

The second build always fails with
cc1plus: error: pch/pch.hpp.gch: not used because '_REENTRANT' not undefined [-Werror=invalid-pch]

Reversing the TILES=0|1 build order only changes the error :
cc1plus: error: pch/pch.hpp.gch: not used because '_XOPEN_SOURCE' not defined [-Werror=invalid-pch]

Removing PCH between builds does solve the problem (rm -f pch/pch.hpp.{gch,pch}).

(Cross-link to the PR introducing this change : #42535 )

@andrei8l
Copy link
Contributor

andrei8l commented Aug 2, 2020

That makes more sense, thanks. That's a limitation of make and I don't know how to work around it. Running make clean when changing project options should be mandatory (saner build systems also enforce it...)

edit: and just to be clear: you gain nothing by skipping make clean in this case since your extra flags invalidate ccache as well. It's a full rebuild either way

@andrei8l
Copy link
Contributor

andrei8l commented Aug 2, 2020

Actually a workaround might be to infix -tiles in the pch's name when TILES=1 (and maybe similar for SOUND, etc..?). It's pretty ugly but it should work

@nikow
Copy link
Contributor Author

nikow commented Aug 2, 2020

Excuse me, step 3. Autogen and call ./configure is mistake on my side. Is there a way to build both version (text one and tiles one) without using PCH=0 flag? If not, i think that should be mentioned in compilation docs somewhere.

@andrei8l
Copy link
Contributor

andrei8l commented Aug 2, 2020

In-between make TILES=0 and make TILES=1, you can either

  1. run rm {tests/,}pch/pch.hpp.{gch,pch} as mentioned above (note: this will still likely fail if you change other flags besides TILES)
  2. copy the target binary, then run make clean
  3. run make install, then make clean

I'm not really sure if that is acceptable workflow for this project, so I won't submit a documentation change. The workaround I mention above is also pretty untenable for all the defines in our current Makefile (and I personally am not interested in writing it atm)

@anothersimulacrum
Copy link
Member

There's no real consideration for building both tiles and curses sequentially, but it is expecting that you make clean between each recompile with different make flags, so option 2 or 3 would be what I'd generally expect for that.

@jbytheway
Copy link
Contributor

If one wishes to build both tiles and curses then it's best to use the CMake build and separate build dirs.

@KorGgenT KorGgenT added the Code: Build Issues regarding different builds and build environments label Aug 11, 2020
@stale
Copy link

stale bot commented Sep 10, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Please do not 'bump' or comment on this issue unless you are actively working on it. Stale issues, and stale issues that are closed are still considered.

@stale stale bot added the stale Closed for lack of activity, but still valid. label Sep 10, 2020
@stale
Copy link

stale bot commented Oct 12, 2020

This issue has been automatically closed due to lack of activity. This does not mean that we do not value the issue. Feel free to request that it be re-opened if you are going to actively work on it

@stale stale bot closed this as completed Oct 12, 2020
leycec added a commit to leycec/raiagent that referenced this issue Jul 15, 2021
This commit resolves issue #102, kindly submitted by twice-the-fun
@2xsaiko, by bumping Cataclysm: Dark Days Ahead to its most stable
release *and* significantly refactoring our ebuild. Specifically, this
commit:

* Bumps C:DDA to 0.9F (Frank).
* Adds a new "pch" USE flag controlling precompiled header support.
  Sadly, enabling this flag prevents the "ncurses" and "sdl" USE flags
  from both being enabled concurrently. Why? Because
  CleverRaven/Cataclysm-DDA#42598, for which there exists no sane
  workaround. For this reason, we advise disabling the "pch" USE flag
  for "games-roguelike/cataclysm-dda".
* Patches away a growing laundry list of Gentoo QA notices caused by
  unsafe and non-portable globally scoped  behaviour in makefiles.
* When compiling with g++, conditionally removes the Clang-specific
 "-Wno-unknown-warning-option" option unsupported by g++ from makefiles.
* Installs C:DDA ".desktop" and icon files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code: Build Issues regarding different builds and build environments stale Closed for lack of activity, but still valid.
Projects
None yet
Development

No branches or pull requests

6 participants