Commit graph

1285 commits

Author SHA1 Message Date
Kp 1f03083b68 Add support for generating clang compilation database 2019-05-26 00:44:37 +00:00
Kp c43b9cd430 Fix builddir prefix/suffix confusion
Commit 0e81c05 moved the offending line, but it was already wrong in
54d57a37c9.

Fixes: 0e81c0594e ("Move settings that affect the build to UserBuildSettings")
2019-05-26 00:44:37 +00:00
Kp 7e01a658c6 Prefer storing .sconsign in a build/ subdirectory 2019-05-26 00:44:37 +00:00
Kp 39303358c8 Fix subsequent tests after detecting Boost.Config
Fixes: 1131868f61 ("Fix -Wimplicit-fallthrough for non-Boost users")
2019-05-06 00:36:16 +00:00
Kp 1131868f61 Fix -Wimplicit-fallthrough for non-Boost users
Users who do not install Boost cannot include <boost/config.hpp>.
SConstruct handled this by disabling the macro DXX_BOOST_FALLTHROUGH,
but did not override gcc's default-enabled (via -Wextra)
use of -Wimplicit-fallthrough=3, so users would get a fallthrough
warning and the build would fail.  Adjust this area to explicitly probe
for -Wno-implicit-fallthrough when Boost.Config is not available.

Fixes: 063bf29225 ("Enable -Wimplicit-fallthrough=5; fix resulting breaks")
Reported-by: Jayman2000 <https://github.com/dxx-rebirth/dxx-rebirth/issues/417>
2019-05-04 21:58:18 +00:00
Kp d6b2ba1775 Fix gcc-4.9 build
gcc-4.9 lacks std::cbegin, std::cend.  Fortunately, nothing in the code
uses those, so remove tests for them.

Fixes: 5e434cbe95 ("Require availability of C++11 begin")
2019-04-28 00:53:40 +00:00
Kp 063bf29225 Enable -Wimplicit-fallthrough=5; fix resulting breaks
This enables using -Wimplicit-fallthrough with ccache+distcc, which
strip the fallthrough comments, but do not strip the attribute
annotationns.
2019-04-04 04:29:03 +00:00
Kp 5e434cbe95 Require availability of C++11 begin
Remove the fallback to Boost.Begin.  C++14 is now the minimum supported
standard, and any conforming C++14 compiler should have a working C++11
std::begin.
2019-04-04 04:29:03 +00:00
Kp ca1ed8602f Add test for gcc bug #82541 2019-02-11 01:53:44 +00:00
Kp 7558795edd Fix sharepath confusion when building both targets
Processing sharepath in SConf is incorrect, because targets can share a
build directory (and therefore an SConf run), but not share a sharepath.
Move sharepath handling out of SConf.  Move DXX_USE_SHAREPATH handling
from CGameArg to GameArg, since one game can be built with a sharepath
while the other is built without.
2019-01-20 05:36:56 +00:00
Kp 20c56cd50b Fix missing comma in SConstruct test
The comma was omitted to discourage putting anything after the last
element.  This was fine when there were multiple elements, but with only
one value, the missing comma causes this not to be a tuple as intended.
Add a comma to fix the test.  Add some additional comments on supported
C++ versions by gcc major version.
2019-01-01 04:54:34 +00:00
Kp bc666fb9e0 Require C++14 in SConstruct tests
Recent code changes require use of return type deduction, which is only
standard in C++14 and later.  Require C++14.  In practice, this changes
nothing, because the minimum supported compiler versions were already
choosing C++14.  This change rejects older compilers that were already
unsupported.
2018-12-31 04:46:16 +00:00
Kp 82f2f17c66 Add comment to SConstruct __preferred_win32_linker_options 2018-12-30 00:43:58 +00:00
Kp a705104e84 Check PHYSFS_init return value
PHYSFS_init is not guaranteed to succeed.  Using PHYSFS functions after
PHYSFS_init fails is likely to fail badly.  On Windows, failure may take
the form of a crash in ntdll.  Avoid this by exiting gracefully.
2018-12-08 23:36:18 +00:00
Kp 24cc62caa3 Increase version to 0.61.0
Using 0.59.100 on master, which is well ahead of the 0.59.100 beta tag,
leads to confusing reports.  Raise the version number to disambiguate
this.
2018-12-01 17:14:52 +00:00
Kp 4d3612e453 Do not modify UserBuildSettings in SConf
Creating an attribute on UserBuildSettings during SConf breaks
clean/help, which do not run configure tests.  Remove that and add a
method to return the value the attribute would have had.

Reported-by: derhass <https://github.com/dxx-rebirth/dxx-rebirth/issues/412>
Fixes: 1be414217c ("Add build time flag to choose whether to enable ADL MIDI support")
2018-10-21 20:09:49 +00:00
Kp 1be414217c Add build time flag to choose whether to enable ADL MIDI support
Since ADL MIDI is not packaged on some distributions, default the option
to off.
2018-10-15 00:51:53 +00:00
JP Cimalando ccb91d7362 allow libADLMIDI to be loaded dynamically 2018-10-08 05:02:02 +02:00
JP Cimalando cabe06e895 WIP ADLMIDI 2018-10-04 12:06:27 +02:00
Kp eab2bf4105 Enable -Wduplicated-branches, -Wduplicated-cond when supported 2018-10-01 03:52:05 +00:00
Kp 56d44459d4 Enable SHAREPATH for non-LinuxPlatformSettings 2018-09-14 02:20:55 +00:00
Kp 45ee65bc7e Make host_platform msys an alias for win32
User jammer1 reports that Python under MSYS2[1] reports a `sys.platform`
of `msys`.  For the limited purposes Rebirth requires, this platform can
be treated as if it were `win32`.  Add a mapping to apply this change
automatically, so that users do not need to set it on the command line.

Reported-by: jammer1 <https://github.com/dxx-rebirth/dxx-rebirth/issues/405>

[1]: http://www.msys2.org/
2018-09-11 01:10:57 +00:00
Kp 38d5bd6b86 Fix Windows build
Fixes: e6e0d525b6 ("Use SCons.Node in place of bare path strings")
2018-09-11 01:10:57 +00:00
Kp e6e0d525b6 Use SCons.Node in place of bare path strings 2018-09-09 01:00:39 +00:00
Kp e27f341acd Fix display of failed PCH node generation
enable_build_failure_summary=1 assumed that the command to display was a
list.  For internal pseudo-commands, such as write_pch_inclusion_file,
the command was a string, so calling ' '.join() was incorrect.  When the
output is not a list, pass it through unchanged.
2018-08-29 01:47:42 +00:00
Kp ec1cf005b6 Enable -Wformat-truncation
Add macro cf_assert ("control flow" assert) to hint to gcc that certain
conditions are impossible.  Use it to avoid generating range checks for
situations that never happen.  If the event did happen, the only
consequence would be truncated UI text, rather than a correctness
problem.
2018-08-26 18:10:36 +00:00
Kp 6be3c0e13a Fix PCH conditional nesting 2018-08-24 02:58:21 +00:00
Kp bba8a327a0 Remove use of -Wno-implicit-fallthrough 2018-08-24 02:58:21 +00:00
Kp be18f54d06 Simplify SConstruct StaticObject hook
The prior design was meant to allow the hook to be called instead of the
normal function, with the hook chaining to the normal function and then
performing other work as needed.  This flexibility is unnecessary, and
complicates improvements elsewhere.  Replace it with a hook that is
called with the result of the regular StaticObject call.
2018-08-24 02:58:21 +00:00
Kp 3f164f494d Unpack LazyObjectConstructor loops
Use of the comprehensions makes the code less readable and harder to
modify.  The performance benefit, if any, is in the noise.  Switch to
an unpacked form.
2018-08-24 02:58:21 +00:00
Kp 92cc4bd4ff Handle Python3 bytes vs. str in Git.__compute_extra_version 2018-08-24 02:58:21 +00:00
Kp 1197f568bc Add CHOST qualifier to CXX, RC 2018-08-20 00:34:15 +00:00
Kp 8eff5802b6 Add explicit check for SDL_JOYSTICK_DISABLED 2018-08-03 04:08:12 +00:00
Kp f491059ed7 Enable building with SDL2
This commit enables Rebirth to build with SDL2, but the result is not
perfect.

- SDL2 removed some sticky key support.  Rebirth may behave differently
  now in this area.
- SDL2 removed some key-repeat related support.  Rebirth may behave
  differently now in this area.
- SDL2 gained the ability to make a window fullscreen by sizing it to
  the desktop instead of by changing the desktop resolution.  Rebirth
  uses this, and it mostly works.
  - Resizing while in the automap does not notify the automap code, so
    the view is wrong until the player switches out of automap mode and
    back in.
- SDL2 changed how to enumerate available resolutions.  Since
  fitting the window to the desktop is generally more useful than
  fitting the desktop to the window, I chose to drop support for
  enumerating resolutions instead of porting to the new API.  Users can
  now enter an arbitrary window dimension and Rebirth will make an
  attempt to use it.
  - It might be useful to cap the window dimension at the desktop
    dimension, but that is not done yet.
  - Entering fullscreen mode through the Controls->Graphics submenu
    failed to notify the relevant subsystems, causing the rendered
    content not to rescale.  For now, compile out the option to toggle
    full screen through that menu.  Toggling through Alt+Enter works
    properly.

Despite these quirks, this is a substantial improvement over the prior
commit, where SDL2 cannot be used at all.  The remaining issues can be
resolved in future work.

References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/82>
2018-07-28 23:22:58 +00:00
Kp 19699037ce Move d2x-rebirth/main/bmread.cpp -> similar/main/bmread.cpp 2018-07-18 04:39:28 +00:00
Kp 20f1934312 Move Redbook audio behind DXX_USE_SDL_REDBOOK_AUDIO
Currently, DXX_USE_SDL_REDBOOK_AUDIO is an alias for !SDL2.  However,
this patch enables interested users to readily patch out Redbook even
for SDL1.

References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/82>
2018-07-14 17:23:15 +00:00
Kp 7d4c521382 Fix SConf tests for Windows target
On Windows, SDL headers define `main` to `SDL_main` in addition to doing
it through `pkg-config`.  The countering `#undef` must occur after the
headers are included.  Commit 2a82207 changed the `#undef` to occur too
early.  Linux works fine, but Windows broke.

Move the `#undef` back down.  Switch to named format parameters to make
it easier to maintain.

Fixes: 2a82207e91 ("Add unit tests for valptridx parameter validation")
2018-06-30 18:59:53 +00:00
Kp 2a82207e91 Add unit tests for valptridx parameter validation 2018-06-17 05:04:38 +00:00
Kp 9b2d5d5162 Add debug hook $DXX_SCONS_DEBUG_USER_SETTINGS to log user_settings init
For the benefit of users less familiar with how setup is handled, add a
hook triggered by $DXX_SCONS_DEBUG_USER_SETTINGS to log initialization
of `user_settings` so that users can trace which values combined to
produce the observed results.
2018-06-17 05:04:38 +00:00
Kp 2f4524d3c2 Add screenshot=none to disable screenshot support
Per comment from kreator, some Apple systems now ship without a working
print screen key.  It makes no sense to provide print screen support
bound to a key which does not exist.  Add `screenshot=none` and activate
it on OS X to remove the unreachable screenshot support.
2018-06-16 04:13:37 +00:00
Kp 479235d5bc Mark variadic forwarding constructor as constexpr
This is safely ignored when the constructor cannot satisfy `constexpr`.
Without this modifier, forwarding to `constexpr` constructors is not
`constexpr`, which causes build failures.

clang-5 with `sconf_cxx11_inherit_constructor=force-failure`:
```
    similar/main/gauges.cpp:553:61: error: constexpr constructor's 1st parameter type 'const (anonymous namespace)::hud_x_scale_float' (aka 'const hud_scale_float<'x'>') is not a literal type
    similar/main/gauges.cpp:432:7: note: 'hud_scale_float<'x'>' is not literal because it is not an aggregate and has no constexpr constructors other than copy or move constructors
```

Fixes: 893e8cde06 ("Combine hud gauge parameters")
2018-06-12 02:53:06 +00:00
Kp bf84c3be4e Improve SCons diagnostics for missing required headers 2018-06-06 04:53:45 +00:00
Kp 784213ec1f Avoid magic strings for LazyObjectConstructor dict keys
Replace magic strings with sentinel objects, so that mistakes are
reported as missing variables, rather than being legal at parse time and
incorrect at runtime.
2018-05-17 05:30:28 +00:00
Kp 09cebc080c Undefine blank SHAREPATH
If user_settings.sharepath is configured to be blank in SConstruct, omit
the C preprocessor macro SHAREPATH instead of defining it to expand to
an empty string.  Adjust the C++ code that uses the macro SHAREPATH to
handle its absence:
- Clearer output in help text
- Skip adding blank SHAREPATH to the PhysFS search path.

As a nice side effect, this enables SHAREPATH on Windows, which could be
helpful for builds shipped with an installer that places game files in a
well-known location (such as "C:\Games\Descent").  Previously,
!defined(__unix__) systems did not add SHAREPATH to the PhysFS search
path, even when one was defined.
2018-05-17 02:49:15 +00:00
Kp 457022db48 Require C++11 static_assert
- Remove the one test that clang-5 still fails.
- Require all remaining tests to pass using only C++11 native
  static_assert.
- Remove preprocessor-based alternative static_assert implementations.

gcc-8 adds calls to static_assert with a comma inside its first
argument in the implementation of std::vector.  This is legal within the
standard, but conflicts with Rebirth's use of static_assert as a
two argument preprocessor macro.  The macro is not substantially useful,
and was only present to compensate for the clang limitation removed in
the previous commit.  Remove the macro.

References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/388>
2018-05-05 22:33:55 +00:00
Kp 7249e4569f Adapt PCHManager to Python 3 __new__ rules
Python 2 permitted defining __new__, then deleting it once it had been
used.  Python 3 does not directly reject that pattern, but instead
always fails with an error about wrong number of arguments to object().
Switch to a simple classmethod that is explicitly invoked by the first
__init__().
2018-04-30 05:31:16 +00:00
Kp 0a5e9eb592 Adapt to Python 3 strict bytes vs str rules 2018-04-30 05:31:16 +00:00
Kp 6148327e4b Adapt configure tests to Python 3 filter API change
In Python 3, filter returns an object that can be iterated to get the
filtered content.  However, there is no way to reset the object, so it
is useless for persistence.  Spend the one iteration copying the data
into a tuple, which can be iterated multiple times.
2018-04-30 05:31:16 +00:00
Kp 8b4586bd20 Adapt PreservedEnvironment to Python 3 dictionary API changes
Python 3 `dict.keys()` returns an object that cannot be added to other
instances of itself.  Pass the returned objects as a tuple, then let the
callee use itertools.chain to combine them during iteration.
2018-04-30 05:31:16 +00:00
Kp a3d6bdd3f1 Add compatibility shims for Python 3 dictionary API change
Python 3 removed `dict.keys` and `dict.items`, then renamed
`dict.iterkeys` and `dict.iteritems` to `dict.keys` and `dict.items`,
respectively.  The iteration semantics are preferable here, so add shims
to use the iteration API under a version-appropriate name.

Change PreservedEnvironment.__getitem__ back to a class method, instead
of an instance variable.  Python 3 refuses to search the instance
dictionary for __getitem__, so the optimization of copying
`self.flags.__getitem__` to `self.__getitem__` breaks in Python 3.
2018-04-30 05:31:16 +00:00
Kp 1c0001d31d Fix parsing SConstruct file lists in Python 3
Python 3 changed the rules for list comprehensions, so the comprehension
can no longer see a class-scope variable without a class qualifier.  The
class qualifier is not legal until the class is finished.  Work around
this limitation by expanding the use inline.
2018-04-30 05:31:16 +00:00
Kp 1097630e42 Simplify host_platform normalization
OpenBSD 6 uses `openbsd6` as its sys.platform.  Strip trailing numbers,
then remove the hack for converting `linux2` into `linux`.  This should
prevent compatibility problems when OpenBSD 7 is used.
2018-03-27 03:49:34 +00:00
Kp 4b39cca42e Clarify SConf output when rejecting a header
Commit 265af2b9e5 added an extra test for whether the header could be
preprocessed, but reused the string shown when an empty test program is
compiled.  This can confuse users since the same message is shown twice.
Differentiate the messages.

Fixes: 265af2b9e5 ("Extend SConf diagnostics for failed system headers")
2018-03-27 03:49:34 +00:00
Kp 1527d14c2d Fix SConf png test for gcc-4.9
gcc-4.9 warns (and due to -Werror, errors) for `png_time pt{}` because
the members are not explicitly initialized.  This code is compiled, but
never run, so the explicit initialization is unnecessary.  Later
versions of gcc accept both versions of this code without complaint.

Fixes: 131c1b9f4d ("Add support for PNG screenshots")
2018-03-24 21:33:29 +00:00
Kp 1c92b448c8 Add d_level_object_state to wrap Objects and related data 2018-03-12 03:43:46 +00:00
Kp 4d318b9177 Clarify SDL1 vs SDL2 SConf messages 2018-03-02 03:19:02 +00:00
Kp fab7eb39c3 Flatten GL lists in SConstruct
This is a longstanding cosmetic issue.  Appending a tuple to a list
retains the tuple structure, which is then printed later.  Append it as
a list so that it is flattened.
2018-02-18 18:52:22 +00:00
Kp f904f76c99 Add tool version suboptions show_assembler_version, show_linker_version
OpenBSD clang does not handle `-print-prog-name=as` in a useful manner.
Since this query is purely diagnostic, add an undocumented knob to
suppress the query.
2018-02-18 18:52:22 +00:00
Kp 131c1b9f4d Add support for PNG screenshots 2018-02-18 00:42:42 +00:00
Kp 754d34f750 Fix PCH build 2018-02-18 00:42:42 +00:00
Kp e7aedfff52 Whitelist openbsd6 as valid host_platform in SConstruct
thfrwn reports that OpenBSD (almost) works as-is, except that its
Python `sys.platform` is not in the allowed values list.  Add it to the
list.  By happy accident, unhandled `host_platform` is treated as
`'linux'` and `'linux'` produces the right result for OpenBSD.

Requested-by: thfrwn <https://github.com/dxx-rebirth/dxx-rebirth/pull/359>
2017-12-24 00:28:35 +00:00
Kp f73b783095 Generate kconfig udlr relations at build time 2017-12-24 00:28:35 +00:00
Kp c09aab491b Fix max_buttons_per_joystick=0 max_hats_per_joystick!=0 build
Internally, hats are treated as a group of 4 buttons.  Disabling all
buttons while not disabling all hats caused a build error.  Since no one
reported this, this configuration is likely not used.  Make the simple
fix of coercing max_hats_per_joystick to 0 when max_axes_per_joystick is
0.
2017-12-24 00:28:35 +00:00
Kp 6043168d51 Move various SDL-only texture mapping functions to !DXX_USE_OGL
The OGL build compiles, but does not use, various texture mapping
functions.  Move these to be built only for the SDL build.
2017-11-01 02:01:21 +00:00
Kp 3fbc710ec5 Move various SDL-only scanline functions to !DXX_USE_OGL
The OGL build compiles, but does not use, various scanline functions.
Move these to be built only for the SDL build.
2017-11-01 02:01:20 +00:00
Kp 3276590084 Merge branch 'psyke83/rpi' into master
psyke83 reports that Debian distributions for Raspberry Pi now require a
different name for some video libraries.  Merge psyke83's SCons
enhancements to add support for the new names while retaining support
for the old names.
2017-10-26 02:02:50 +00:00
Kp 1eb29c6e71 Set raspberrypi EnumVariable ignorecase=2 to avoid user confusion
ignorecase=1 coerces the user's input only for validation, but retains
the original case for later processing.

ignorecase=2 coerces the user's input for all purposes, and retains the
coerced form for later processing.

Since other code compares the `raspberrypi` variable to specific values
from the whitelist, user input must be mapped to that whitelist both for
SCons validation and for that later code.  With ignorecase=1, a user
could set `raspberrypi=MESA`, which would pass SCons validation, but
then not be treated as equal to `mesa` when computing default values.
With ignorecase=2, `raspberrypi=MESA` will be recorded as `mesa` and
compute the desired default value.

Fixes: 166b1ecd4d ("RPI: update vendor library names & add Mesa VC4 build support")
2017-10-26 01:58:28 +00:00
Kp 8838b46e65 Suppress PhysFS deprecation errors
PhysFS 2.0 only offers PHYSFS_read/PHYSFS_write for I/O.  PhysFS 3.0
deprecates PHYSFS_read / PHYSFS_write and offers PHYSFS_readBytes /
PHYSFS_writeBytes.  Converting Rebirth to use the new API is somewhat
invasive, and would require dropping support for PhysFS 2.0.

For now, for compatibility with PhysFS 2.0, disable the deprecation
errors and continue to use the older functions.

Reported-by: gabeotisbenson <https://github.com/dxx-rebirth/dxx-rebirth/issues/352>
2017-10-22 04:20:35 +00:00
Conn O'Griofa 166b1ecd4d RPI: update vendor library names & add Mesa VC4 build support
Vendor library has new names to avoid conflicts with Mesa. Update
raspberrypi argument to use new libraries and support Mesa VC4 driver.

* raspberrypi=1 will build against the (newly named) vendor libraries
* raspberrypi=mesa will target building against the VC4 driver.

Both will select GLES by default, but you can target GL for the VC4 driver
via "raspberrypi=mesa opengles=0"
2017-10-22 02:50:13 +00:00
Kp 8d80300e0a Remove obsolete D1 hostage editor code
This code was part of a feature abandoned before retail.  It cannot be
usefully used in campaigns.  Remove it to reduce code size and simplify
later changes.
2017-10-14 17:10:31 +00:00
Kp 3ad6972a03 Read pkg-config modversion before flags, not after
Reading modversion after flags can cause confusing output if the flags
load successfully, but the modversion call fails.
2017-10-14 17:10:30 +00:00
Kp 12369d2dd8 Add SConstruct modeline to set tabstop=4 2017-10-14 17:10:30 +00:00
Kp 8f4a20e65b Set Environment CXX earlier
SCons tries to probe the compiler designated by CXX before Environment()
returns.  Set CXX in the call to Environment so that it probes the
correct tool.
2017-10-14 17:10:30 +00:00
Kp 49da5bd5f7 Suppress blank builddir from CPPPATH 2017-10-14 17:10:30 +00:00
Kp e9d8c3c784 Only include linker version if linker path is available
If resolving the linker path fails, ld_path is not usable to run an
external program, but DXXProgram tried to use it as such.  Test ld_path
before using it.
2017-10-14 17:10:29 +00:00
Kp b9af2dbedb Only shlex.split pkg-config paths from user
Splitting auto-generated paths is wasteful, but almost always harmless
on Linux.  However, Windows uses backslash as a path separator, which
conflicts with its standard meaning as an escape character.  Using
shlex.split on a generated Windows path strips required backslashes,
causing a later failure to find the command.  Move the shlex.split call
to apply only to user-specified paths.

Reported-by: ef314159 <https://github.com/dxx-rebirth/dxx-rebirth/issues/349>
2017-10-14 17:10:29 +00:00
Kp d0f709381d Fix build break when using Windows as a host platform
ef314159 reports that running SCons on Windows fails with an
AttributeError exception.  `os.uname` is not available on Windows, but
SConstruct assumed it was.  Trap the error and report a machine of
`None`, since this is purely for logging.

Reported-by: ef314159 <https://github.com/dxx-rebirth/dxx-rebirth/issues/348#issuecomment-334657171>
Fixes: 1ed7cec714 ("Tighten __builtin_constant_p check to handle gcc-7")
2017-10-07 00:54:55 +00:00
Kp af863fdef7 Parenthesize SCons message() call to print
When print_function is imported (or Python 3 is used), print without
parentheses is an error.  Historically, SCons has used only Python 2 and
has not enabled print_function.  This may change, so add parentheses to
the one affected site.  None of the print_function features are used, so
this should work in both Python 2 and Python 3.
2017-10-07 00:54:55 +00:00
Kp f2a8be23a9 Prefer dict.get() over try/except KeyError in SConstruct 2017-09-26 04:15:50 +00:00
Kp a6a5f7be82 Make vers_id.cpp depend on ${SOURCE_DATE_EPOCH-None} 2017-08-02 02:49:12 +00:00
Kp c9d733dd10 Add experimental Windows manifest 2017-08-02 02:49:12 +00:00
Kp 7b12619c3a Unify resource file compilation 2017-08-02 02:49:12 +00:00
Kp 7378179663 Fix __builtin_constant_p test in LTO mode
LTO allows the compiler to prove variable values that non-LTO mode
cannot prove.  The workaround for the gcc-7 __builtin_constant_p
quirk incorrectly caused LTO on older gcc to report __builtin_constant_p
as unsupported.  Fix this by adding a stub asm() statement to hide the
value of the input parameter from the compiler.

Fixes: 1ed7cec714 ("Tighten __builtin_constant_p check to handle gcc-7")
2017-08-02 02:49:12 +00:00
Kp 4128ce2971 Use compiler-provided integer_sequence when it is depth-efficient
Early implementations of integer_sequence used a naive implementation
that required one level of template depth per additional integer in the
sequence.  Rebirth uses a private alternate implementation named
make_tree_index_sequence that requires only log(N) steps for an
N-element index_sequence.  Recent versions of gcc ship a log(N) version
of integer_sequence.  Probe for that version and, if found, use it
instead of the private implementation, on the theory that the compiler
writers did at least as good a job as I did, and possibly better if they
were able to leverage compiler implementation details.
2017-07-26 03:15:59 +00:00
Kp 8ccf0e5301 Add PHYSFS_read wrapper support
- Add wrappers for PHYSFS_read and its convenience functions.  Poison
  the memory before calling PHYSFS, so that any uninitialized bytes
  (likely caused by a short read) are reported if the caller tries to
  access the value anyway.
- Add SConstruct options to enable wrapping, so that users do not need
  to enumerate the wrapped functions manually.
- Fix link failure when using LTO+wrappers.
2017-07-26 03:15:58 +00:00
Kp b83ac0acfa Update SConstruct comment regarding gcc bug #70844 (-Wuseless-cast) 2017-06-17 23:05:16 +00:00
Kp 57b67078da Exclude valptridx.tcc from PCH
It is not meant to be included in every file.  Starting in gcc-7, static
functions declared in valptridx.tcc generate -Wunused-function warnings
if the including file does not instantiate any templates that use the
static function.  Avoid these warnings by including the tcc only in a
file that is guaranteed to instantiate templates that use these
functions.
2017-06-10 03:31:04 +00:00
Kp 73057ad8ec Suppress unhelpful gcc-7 warnings for now
gcc-7 warning -Wformat-truncation would be good to fix, but the compiler
does not offer an acceptable solution yet.

gcc-7 warning -Wimplicit-fallthrough requires more analysis of the
diagnosed sites to identify which, if any, require a resolution other
than suppressing the warning.
2017-06-10 03:31:04 +00:00
Kp 5b12f28564 Add workaround for unwanted gcc-6 "used but never defined" warning
gcc-6 issues a "used but never defined" warning for functions which are
declared, never defined, and used only in contexts which are later
deleted by the optimizer.  If the function were actually used, the link
would fail.  Switch to a complicated mechanism to define the function
while keeping it out of line so that __attribute__((__error__)) is
triggered as intended.
2017-06-10 03:31:03 +00:00
Kp 1ed7cec714 Tighten __builtin_constant_p check to handle gcc-7
Compile time sanity checks are built on gcc's __builtin_constant_p.
This intrinsic is useful for optimization and for some simple forms of
compile-time checks (such as the infamous open(2) missing mode), but
upstream does not guarantee that it will work reliably for more
complicated checks.  Starting in gcc-7.1, __builtin_constant_p returns
an incorrect result of true for the vm_vec_sub expression

    `(a.x == b.x && a.y == b.y && a.z == b.z)`

even when the blamed sites clearly cannot prove that the inputs are
equal.  The useful result would be to return true if, and only if, the
inputs were provably identical; inputs which might be identical at
runtime, or might not, would return false.  Based on a bug filed with
gcc and the developer comments there, it appears many projects have
assumed this intrinsic is usable in this way, but the gcc developers do
not guarantee that it can be used this way.  Additionally, they believe
affected projects are rare and were wrong to use this intrinsic, so they
have no plans to fix this regression.

For more details, see gcc bug #72785
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72785>.  For some more
pointed commentary on this change in gcc, see Linus' kernel commit
474c90156c8dcc2fa815e6716cc9394d7930cb9c
<https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=474c90156c8dcc2fa815e6716cc9394d7930cb9c>.

Update the SConf test to include the reproducer shown by Markus
Trippelsdorf in gcc bug #72785, comment #0.  This reproducer compiles
cleanly on <gcc-7, causing no change in semantics on older compilers.
Affected versions of gcc-7 will miscompile this reproducer into a link
error, causing SConf to record that the compiler does not optimize
__builtin_constant_p.  This is pessimistic, since even affected versions
of gcc-7 can handle some simple uses of __builtin_constant_p correctly.

This is a quick fix to get gcc-7 users working.  Upstream seems
disinclined to revert to the more useful semantics of <gcc-7 or to
introduce an alternative intrinsic with more helpful semantics.  As a
minor enhancement for Rebirth, it would be nice to probe the limits of
gcc-7's handling of __builtin_constant_p so that cases it handles
correctly could be enabled for gcc-7 users, while still blacklisting the
more complicated checks that gcc-7 miscompiles.

Thanks to Markus Trippelsdorf for providing a minimal reproducer to
detect the affected gcc versions.

Reported-by: parkerlreed <https://github.com/dxx-rebirth/dxx-rebirth/issues/337>
2017-06-03 17:11:12 +00:00
Kp fc53137237 Extend SDL test to check for OpenGL mismatch
When Rebirth is configured to use OpenGL, it cannot start with an SDL
that lacks OpenGL support.  Detect this mismatch at build time.  Require
the user to resolve the conflict by disabling Rebirth OpenGL or by
enabling SDL OpenGL.
2017-06-03 17:11:11 +00:00
Kp 9478d1e6a5 Add custom terminate handler on Windows 2017-04-22 21:23:56 +00:00
Kp b98053a34f Fix Windows net_udp.cpp build
The Windows implementation of inet_ntop incorrectly omits the `const`
qualifier on the input address.  This broke the Windows build, since
Rebirth passes a const-qualified input address, as permitted by POSIX.

Some Windows cross-compilers, such as mingw32, lack a definition of
inet_ntop entirely.  For such environments, fall back to inet_ntoa and
disallow building with IPv6.

Rework the formatting and add a Windows-specific test for whether
inet_ntop is available.  As inet_ntop is specified by POSIX, assume all
modern non-Windows platforms support it.
2017-04-22 21:23:56 +00:00
Kp 2dd4384d9d Move _WIN32_WINNT setup to SConf 2017-04-22 21:23:55 +00:00
Kp 6c98a3d61b Summarize failed nodes 2017-04-22 21:23:55 +00:00
Kp d0747bd481 Rename user_settings.LDFLAGS to user_settings.LINKFLAGS
SConstruct prefers to refer to linker flags for the main executable as
LINKFLAGS, not LDFLAGS.  Rename the internal storage to eliminate a
special case in accessing it.  Continue to use the environment variable
$LDFLAGS as an initial value, since many tools expect to pass linker
flags through $LDFLAGS.
2017-04-22 21:23:54 +00:00
Kp 9688c50e7e Add warning when build arguments override unknown variable warning 2017-04-08 16:48:18 +00:00
Kp c7a510df22 Only print toolchain information if compilation is enabled 2017-04-08 16:48:18 +00:00
Kp a815541ef5 Fix check_header_includes=1 poison.h 2017-02-19 19:33:36 +00:00
Kp 625bfde977 Tighten test for warning -Wuseless-cast
zicodxx reported a compiler error when using inheriting constructors
when using an unspecified environment.  Investigation shows that gcc-6.x
has a regression that causes spurious -Wuseless-cast warnings where the
compiler automatically synthesizes a cast, then warns the user that the
synthesized cast is useless.

Compensate for this by extending the -Wuseless-cast testcase to provoke
this bug, if present.  Affected users will lose -Wuseless-cast, but
their build will succeed.

Reported-by: zicodxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/316>
2017-02-08 23:34:41 +00:00