Rename symbol IPv6 to DXX_USE_IPv6 to show that it is a DXX
symbol, not one inherited from a library. Move it to dxxsconf.h to
shorten the command line.
This is a mostly automated transform, but the changes to SConstruct were
manual.
git grep -wl IPv6 -- '*.h' '*.cpp' | xargs sed -i -e 's/^\s*#ifdef \(IPv6\)$/#if DXX_USE_\1/' -e 's/\s*#\(el\)\?if \(.*\)defined(\(IPv6\))/#\1if \2DXX_USE_\3/'
Rename symbol USE_UDP to DXX_USE_UDP to show that it is a DXX
symbol, not one inherited from a library. Move it to dxxsconf.h to
shorten the command line.
This is a mostly automated transform, but the changes to SConstruct were
manual.
git grep -l USE_UDP -- '*.h' '*.cpp' | xargs sed -i -e 's/^\s*#ifdef \(USE_UDP\)$/#if DXX_\1/' -e 's/\s*#\(el\)\?if \(.*\)defined(\(USE_UDP\))/#\1if \2DXX_\3/'
Rename symbol USE_TRACKER to DXX_USE_TRACKER to show that it is a DXX
symbol, not one inherited from a library. Move it to dxxsconf.h to
shorten the command line.
This is a mostly automated transform, but the changes to SConstruct were
manual.
git grep -l USE_TRACKER -- '*.h' '*.cpp' | xargs sed -i -e 's/^#ifdef \(USE_TRACKER\)$/#if DXX_\1/' -e 's/#\(el\)\?if \(.*\)defined(\(USE_TRACKER\))/#\1if \2DXX_\3/'
Rename symbol USE_SDLMIXER to DXX_USE_SDLMIXER to show that it is a DXX
symbol, not one inherited from a library. Move it to dxxsconf.h to
shorten the command line.
This is a mostly automated transform, but the changes to SConstruct and
inferno.cpp were manual.
git grep -l USE_SDLMIXER -- '*.h' '*.cpp' | xargs sed -i -e 's/^#ifdef \(USE_SDLMIXER\)$/#if DXX_\1/' -e 's/#\(el\)\?if \(.*\)defined(\(USE_SDLMIXER\))/#\1if \2DXX_\3/'
clang does not understand -Wuseless-cast. Passing -Wuseless-cast to
clang causes clang to fail the compile. Resolve this by adding an SConf
test for -Wuseless-cast instead of adding it unconditionally. It cannot
be put in the compiler preferred options tuple since it must be set
before the test for whether casting a ptrdiff to int is useless.
The folded form combined multiple targets into one, which is not the
desired result.
'''
unfolded
l=['gcc5,', 'mingw5,'] e='gcc5,' p=('gcc5', '')
l=['gcc5,', 'mingw5,'] e='mingw5,' p=('mingw5', '')
folded
l=['gcc5,', 'mingw5,'] e='mingw5,' p=('gcc5', '', 'mingw5', '')
'''
import itertools
l = ['gcc5,', 'mingw5,']
print('unfolded')
for e in l:
for p in itertools.product(*[v.split('+') for v in e.split(',')]):
print("l=%r e=%r p=%r" % (l, e, p))
print('folded')
for p in itertools.product(*[
v.split('+') \
for e in l \
for v in e.split(',') \
]):
print("l=%r e=%r p=%r" % (l, e, p))
Field width conversion `.*` always takes an `int`.
On Win32, casting `long` to `int` triggers a `-Wuseless-cast` warning.
Omitting the cast works correctly.
On Linux/amd64, casting `long` to `int` works correctly.
Omitting the cast triggers a `-Wformat` warning.
Add a macro that conditionally expands to `static_cast<int>` or to ``,
as necessary for the target platform.
Newer SCons applied a performance optimization that breaks a technique
used in the check_header_includes=1 build. Switch to a technique that
should work reliably on old and new SCons, although with slightly
reduced efficiency in both cases. The effective performance penalty
should be unnoticeable and only applies to developers building with
check_header_includes=1.
The C++11 required feature string was computed once per configured
environment. When two or more environments were configured in a single
run, this was wasteful. Reorder the SConf tests to precompute the
string.
Commit 957016621e ("Remove support for
Boost.TypeTraits") removed support for any alternative implementation of
<type_traits>, so C++11 <type_traits> is now required. Move it to
the Cxx11RequiredFeature array to combine it with the other required
feature tests.
Fallback support for Boost.Foreach is broken and no one has reported it.
The minimum required gcc version supports range-based for. Recent Clang
supports range-based for. No Microsoft compilers are supported. Remove
support for the fallback Boost.Foreach and move the C++11 range-based
for test to the Cxx11RequiredFeature array.
Building with Boost.Array fails due to name lookup errors. These could
be fixed, but since no one has reported them and they are fairly old,
Boost.Array appears to be unused. Remove support for it.
Building with std::tr1::array fails due to missing features in
std::tr1:array relative to std::array. No one has reported this either,
so remove support for std::tr1:array.
Move the test for std::array into the Cxx11RequiredFeature list so that
it is run as part of the group test, rather than as a separate
statement.
GCC std::array uses std::size_t for its size_type. On Linux/amd64,
`std::size_t` is `unsigned long`. On Win32, `std::size_t` is
`unsigned int`. This provokes format string warnings because an
unsigned int is passed where the format string declares an unsigned
long. On Win32, `unsigned int` and `unsigned long` are the same size,
so `unsigned long` could have been used to avoid this problem by
maintaining consistency with Linux, but it was not. This may have been
an attempt to achieve bug compatibility with Microsoft's types.
Add a workaround by defining a macro DXX_PRI_size_type in the style of
inttypes.h PRI* macros. Use an SConf test to determine the correct
value by inspecting which compilation runs succeed. Currently, Linux
needs "l", Win32 needs "", and Win64 needs "I64".
Some tests may benefit from the results of earlier tests. Other tests
may give different results if the macros from earlier tests are defined.
SCons dependency checking rejects including dxxsconf.h during testing,
so save the results of self._check_macro and insert them into later
tests. Some tests define their macros in other ways. The macros from
those tests and are not yet inserted.
Boost enable_if works differently from std::enable_if, so the build is
broken when using Boost.TypeTraits. The broken code has been present
for a long time and no one reported it. Remove the fallback to Boost.
Windows 2000 has no support for getaddrinfo. Five years ago (Apr 5
2011), the addition of tracker support
(7f18afd5d7) brought a requirement for
getaddrinfo. Recently, someone with a working Windows 2000 system
reported that Rebirth no longer starts on Windows 2000. Although such
systems should not be connected to the Internet, they may still need
name resolution on a LAN. Add a configure test to probe for getaddrinfo
support and fall back to gethostbyname if needed.
Compiling a binary that works on Windows 2000 requires one of:
* using an ancient SDK that does not declare getaddrinfo
* defining _WIN32_WINNT to exclude Windows XP support
* overriding the SConf test to force failure
Fixes: 7f18afd5d7 ("Client-side implementation for Tracker support by Matt 1360 Vandermeulen including improvements in udp_dns_filladdr and IPv4/IPv6 compability; Very little adjustments by me, too including IPv6 support for Windows (untested); Actual tracker code will follow later as seperate branch when it's done")
Clang becomes confused trying to resolve X::a when:
- both `namespace ::X` and `class ::B::X` exist
- `using namespace B;` is active
even if class ::B::X is only a forward-declaration. Add an SConf test
to recognize when the compiler rejects this pattern and hide the safety
nets that are implemented using it.
Microsoft cmd.exe has strange quoting rules. Where other shells treat
single quote as a quote character, cmd.exe seems to pass it through to
the underlying process. This breaks the vers_id compilation with
strange error messages. In practice, SCons does not need the
no-interpolation semantics that single quote provides, so switch to
double quote for compatibility with Windows. This is probably slightly
less efficient on Bash, since it will now scan the value for expansions.
However, the efficiency loss is tiny compared to overhead elsewhere in
the build.
Per the documentation, on Linux, the default is true. On Windows,
setting it to true causes a Python exception because Windows relies on
disabling inheritance as a hack to close all descriptors, but
inheritance needs to be enabled to capture the output of the child
process.
Reported-by: Mako88 <https://github.com/dxx-rebirth/dxx-rebirth/issues/173>
Fixes: bb3f414128 ("Cache scons subprocess calls")
Move the boilerplate up onto the outer namespace line. Decorate each
collision with a comment stating its purpose, so that compiler error
output echoes the type of collision.
This started as a project to make SConstruct take less time on an empty
build. Unforunately, most of the major gains lie elsewhere and require
deeper changes to the build system. These changes do not help much, but
they are better than nothing.
Add option to compute indirect includes even when not necessary, since
indirect includes influence the inclusion count shown in the comments.
Enabling this option makes SCons work harder for the same output binary.
It should only be used by developers who want to see precise file
inclusion counts.
Current gcc requires a non-PIE cc1plus for working PCH support. If the
chosen compiler is PIE, it will succeed in building the PCH, then fail
when trying to use it.
Per issue from MattWatt, gcc for Raspberry Pi warns about alignment
issues.
Per issue from kreator, clang warns about alignment issues on OS X.
However, it does not warn on x86_64-pc-linux-gnu.
GCC only warns when compiling for a target architecture that requires
alignment, so it does not warn for i686-pc-linux-gnu or
x86_64-pc-linux-gnu.
Using this warning would be nice, but since it only triggers on
architectures not maintained by active developers, it causes more
trouble than it may solve.
Alignment sensitive users will have to get by with software fixups until
an active developer begins targeting alignment sensitive hardware.
Reported-by: MattWatt <https://github.com/dxx-rebirth/dxx-rebirth/issues/119>
Reported-by: kreatordxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/120>
Some builds of SDL lack joystick support. Rebirth requires joystick
support in SDL, even if the user never connects a joystick. Add a call
to SDL_NumJoysticks during the SDL test so that systems without SDL
joystick support fail the "usable library SDL" test.
Test check_compiler_template_parentheses_warning probes for a bug in
gcc-4.6. Upstream fixed the bug in gcc-4.7. Using gcc-4.6 is no longer
supported, so remove the test for the bug.
clang does not support -flto=N syntax for parallel LTO.
Remove -fno-fat-lto-objects too. clang does not understand it;
gcc 4.9 and later default to non-fat LTO.
Fixes: 1037a92d60 ("Allow parallel lto")
Previously, SConstruct tested whether static_assert worked with trivial
constant expressions. Extend the test to more complicated expressions
like the ones used in the program.
Replace the typedef based approach with an inline enum to avoid warnings
about unused local typedefs.
Allow use with compilers that lack working static_assert or that cannot
accept complicated expressions. Add a non-checking definition that uses
the input parameter. This prevents warnings when types or constants are
used only for the static_assert.
Various functions use the non-macro form, so support for =delete is
already mandatory. Remove the remnants of support for compilers which
lack =delete and replace it with a hard stop when the compiler rejects
declaring explicitly deleted functions.
Dynamic linked physfs handles its own zlib dependencies. If the user
links to a static physfs and physfs is built with support for zip files,
then we need to add zlib to the link line.
<gcc-4.7 no longer builds due to incomplete decltype handling
>=gcc-4.7 handles -Wredundant-decls correctly
Remove the SConf test and always set -Wredundant-decls.
Rebirth builds with -Werror=redundant-decls -Werror=undef, which are
triggered by the bcm_host.h. Making gcc treat those paths as
system headers avoids these issues. This was suggested by Kp.
Clang warns for unused static inline functions defined in a source file,
including those defined in a macro in a header, when the macro is
expanded in the source file.
GCC with -Wmissing-field-initializers warns for a={}, but this is a
common construct in Rebirth code to zero-initialize an entire structure.
Users might add -Wmissing-field-initializers or a group option which
enables -Wmissing-field-initializers, so add code to explicitly disable
this warning when the compiler rejects this form of initialization.
Merge Mac OS X specific fixes from btb. The Windows and Linux builds
are unaffected. The OS X changes look sane, but cannot be tested here.
Changes not specific to OS X were previously committed separately.
Requested by btb: https://github.com/dxx-rebirth/dxx-rebirth/pull/12
Remove explicit 'inline' on __builtin_constant_p test, since -Og will
inline simple functions on request but not inline speculatively or
inline complex templates. When testing at -Og with 'static inline',
__builtin_constant_p is marked as functional, but physfsx checks are not
inlined and result in spurious failures. When testing at -Og with
'static', __builtin_constant_p is marked as broken and the physfsx
checks are skipped. When testing at -O2, __builtin_constant_p is marked
as working and the physfsx checks are included.