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.
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.
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.
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.
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")
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")
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.
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.
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>
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.
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.
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")
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>
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"
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.
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.
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.
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>
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")
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.
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")
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.
- 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.
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.
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.
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.
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>
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.
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.
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.