Commit graph

192 commits

Author SHA1 Message Date
Hein-Pieter van Braam-Stewart
0cce213f14 Use -latomic when linking whe using clang on Linux
According to the LLVM documentation when using GNU's libstdc++ clang
will not automatically link with -latomic. This is necessary since we
merged c++11 atomics support.

This fixes linking using Clang on Linux
2021-02-20 16:37:00 +01:00
Rémi Verschelde
ad7710ae5e
Dynamically load libudev.so.1 on Linux if udev=yes
This makes it possibly to run Linux binaries compiled with udev support on
Linux systems which do not provide udev (typically systemd-less distros).

If udev is missing, we fall back to parsing `/dev/input` like when compiled
without udev support (`udev=no`).

Also adding some verbose debug statements to know which method we're using
when debugging Linux joypad issues.

The libudev so wrappers were generated on Mageia 8 with libudev 246.9 using
https://github.com/hpvb/dynload-wrapper:
```
./generate-wrapper.py --include /usr/include/libudev.h --sys-include '<libudev.h>' \
  --soname libudev.so.1 --init-name libudev --omit-prefix gnu_ \
  --output-header libudev-so_wrap.h --output-implementation libudev-so_wrap.c
```

(cherry picked from commits a10c259c1d
and e26a1f807b)

Edit: Updated to version 0.2 of dynload-wrapper to fix symbols clobbering as
done in #46143.
2021-02-18 10:31:31 +01:00
Hein-Pieter van Braam-Stewart
228803e9db Dynamically load libpulse.so.0 and libasound.so.1 on Linux
By generating stubs using https://github.com/hpvb/dynload-wrapper we
can dynamically load libpulse and libasound on systems where it is available.
Both are still a build-time requirement but no longer a run-time dependency.

For maintenance purposes the wrappers should not need to be re-generated
unless we want to bump pulse or asound to an incompatible version. It is
unlikely we will want to do this any time soon.

cherry-pick from 09f82fa6ea
2021-02-17 10:31:52 +01:00
Rémi Verschelde
42d3d9c345
SCons: Fix debug_symbols tests after switch to BoolVariable
Bug introduced in #45679.

Fixes part of #45816.

(cherry picked from commit 849c090343)

Also removes useless `debug_symbols=full` mode.
2021-02-08 22:36:32 +01:00
Rémi Verschelde
f3c030aa47 SCons: Add production=yes option to use production defaults
This is meant for users making custom builds to match the options used on
optimized, official builds.

This enables, on the platforms which support them:
- `use_static_cpp=yes` (portable binaries for Linux and Windows)
- `use_lto=yes` (link time optimizations - note: requires a lot of RAM!)
- `debug_symbols=no` (no debug symbols, smaller binaries)

Also abort when using MSVC with `production=yes`, as:
- It cannot optimize the GDScript VM like GCC or Clang do, leading to
  significant performance drops.
- Its LTO support is unreliable, at least used to trigger crashes last
  we tried it extensively.

All options can still be overridden if specified, and the `dev=yes` option
was changed to also support overrides.

(cherry picked from commit db26871210)
2021-02-05 09:26:09 +01:00
Rémi Verschelde
5506143522
Linux: Enable udev support by default
This has been enabled for years in official binaries, and users making custom builds
may end up not enabling it unknowingly, so it's best if we default to the same as
what official builds do.

The original reason for having it opt-in was likely the addition of a dependency on
libudev, but that should be fairly ubiquitous by now.

(cherry picked from commit e8b69fccbe)
2021-02-02 13:30:54 +01:00
Rémi Verschelde
43ab32ae7e
Linux: Build with use_static_cpp=yes by default for x86_64
This enables `-static-libgcc -static-libstdc++` which help make custom Linux
builds more portable (official builds have been using this option for years).

For some obscure reason Ubuntu 18.04 i386 crashes when using the option for
i386 builds, so let's play it safe and enable for x86_64 only for now.

(cherry picked from commit 1ebd66daff)
2021-02-02 13:30:54 +01:00
Rémi Verschelde
60959b085d
SCons: Add only selected platform's opts to env
Otherwise we can get situations where platform-specific opts with the same name
can override each other depending on the order at which platforms are parsed,
as was the case with `use_static_cpp` in Linux/Windows.

Fixes #44304.

This also has the added benefit that the `scons --help` output will now only
include the options which are relevant for the selected (or detected) platform.

(cherry picked from commit 0f84d8dc49)
2020-12-29 16:02:00 +01:00
Rémi Verschelde
0b38c50311
SCons: Do not define TYPED_METHOD_BIND on Linux/OSX with clang
Port of #43862.
2020-11-25 21:17:48 +01:00
Hugo Locurcio
4907911bf8
Remove debug_symbols=full in favor of debug_symbols=yes
`debug_symbols=yes` will now behave like `debug_symbols=full` did
before. The difference in compressed file sizes is not that large,
which means there isn't much point in having two different values.

This helps make the buildsystem easier to understand.

(cherry picked from commit ff1f0d2cb5)
2020-11-11 15:12:01 +01:00
lawnjelly
c2290dbedd Unified GLES2 / GLES3 Batching
Batching is mostly separated into a common template which can be used with multiple backends (GLES2 and GLES3 here). Only necessary specifics are in the backend files.

Batching is extended to cover more primitives.
2020-10-16 10:34:47 +01:00
Rémi Verschelde
4ad74609ce
Merge pull request #40205 from bruvzg/click-through-3
[3.2] Add mouse event pass-through support for window.
2020-10-01 13:58:24 +02:00
bruvzg
e51fed9d1b
[3.2] Add window click-through support. 2020-09-17 12:36:01 +03:00
Rafał Mikrut
abd7c1833e Added Linux sanitizer with xvfb to github workspace 2020-08-14 12:15:58 +02:00
Rémi Verschelde
f1cdb91f34 SCons: Remove unused DEBUG_MEMORY_ENABLED define
Its last use was removed in Godot 3.0, so it no longer makes sense to define.

Also removed `D3D_DEBUG_INFO` for Windows as it's likely a left over from a
long time ago pre-opensourcing when Godot had some form of Direct3D 9 support?

(cherry picked from commit dcf902df85)
2020-07-24 10:31:57 +02:00
Rémi Verschelde
7bf9787921 SCons: Format buildsystem files with psf/black
Configured for a max line length of 120 characters.

psf/black is very opinionated and purposely doesn't leave much room for
configuration. The output is mostly OK so that should be fine for us,
but some things worth noting:

- Manually wrapped strings will be reflowed, so by using a line length
  of 120 for the sake of preserving readability for our long command
  calls, it also means that some manually wrapped strings are back on
  the same line and should be manually merged again.

- Code generators using string concatenation extensively look awful,
  since black puts each operand on a single line. We need to refactor
  these generators to use more pythonic string formatting, for which
  many options are available (`%`, `format` or f-strings).

- CI checks and a pre-commit hook will be added to ensure that future
  buildsystem changes are well-formatted.

(cherry picked from commit cd4e46ee65)
2020-06-10 15:30:52 +02:00
Rémi Verschelde
98d0bf7d7a assimp: Clean and document buildsystem, prepare for unbundling
- Improve the SCsub to allow unbundling and remove unnecessary code.
- Move files around to match upstream source.
- Re-sync with upstream commit 308db73d0b3c2d1870cd3e465eaa283692a4cf23
  to ensure we don't have local modifications.
- Doesn't actually build against current version 5.0.1 due to the lack
  of the new ArmaturePopulate API that Gordon authored. We'll have to
  wait for a public release with that API (5.1?) to enable unbundling.

(cherry picked from commit 9d8a9ea826)
2020-03-06 23:53:23 +01:00
Rémi Verschelde
75164169c4 SCons: Fix get_compiler_version() to return ints
Otherwise comparisons would fail for compiler versions above 10.
Also simplified code somewhat to avoid using subprocess too much
needlessly.

(cherry picked from commits c7dc5142b5
and df7ecfc4a7)
2020-03-04 14:40:12 +01:00
Pedro J. Estébanez
35dd36ca35 Fix error with linkers other than GNU ld 2020-01-22 22:38:08 +01:00
Rémi Verschelde
6b64c60b0e
Merge pull request #35209 from RandomShaper/fix_pck_embed_linux
Fix error exporting to X11 with embedded PCK
2020-01-16 18:45:20 +01:00
Pedro J. Estébanez
4eeae59293 Fix error exporting to X11 with embedded PCK
Fixes #32513.
2020-01-16 17:47:37 +01:00
Rémi Verschelde
c7b701dfd2 Image: Include S3TC compression via Squish in non-tools build
We already build Squish in templates build for S3TC decompression,
so we can as well expose the compression feature.

Fixes #25640.
2020-01-13 15:58:49 +01:00
qarmin
14c16d6851 Added Thread Sanitizer 2019-08-07 12:01:14 +02:00
Rémi Verschelde
a149e412f7
Merge pull request #24086 from RandomShaper/bundle-pck-to-executable
Enhance game export
2019-07-05 10:28:29 +02:00
Fabio Alessandrelli
aae6c075aa Remove libwebsocket. No longer used, yay! 2019-07-04 15:03:04 +02:00
Pedro J. Estébanez
40f4d3cf0f Add embedded PCK option to PC platforms
The basic point is as in 2.1 (appending the PCK into the executable), but this implementation also patches a dedicated section in the ELF/PE executable so that it matches the appended data perfectly.

The usage of integer types is simplified in existing code; namely, using plain `int` for small quantities.
2019-07-03 21:58:12 +02:00
Rémi Verschelde
b0d41847ed SCons: Use CPPDEFINES instead of CPPFLAGS for pre-processor defines
It's the recommended way to set those, and is more portable
(automatically prepends -D for GCC/Clang and /D for MSVC).

We still use CPPFLAGS for some pre-processor flags which are not
defines.
2019-07-03 09:59:04 +02:00
Rémi Verschelde
1769cbc0e2 SCons: Default to builtin libpng/freetype on Linux
The rationale for keeping those shared by default is that they're typical
dependencies found on any Linux system, and it saves compilation time and
binary size to link their dynamically.

But since official builds default to all-builtin, and Debian/Ubuntu still
don't have libpng16 (which we now require) readily available on all their
supported releases, it's simpler to bundle all the things.

This does not change the fact that those dependencies *can* be unbundled
on Linux, it's only the default option changing.
2019-06-23 10:02:35 +02:00
Ibrahn Sahir
5e24611241 Png driver reworked to use libpng 1.6 simplified API
Wrapped libpng usage in a pair of functions under PNGDriverCommon,
which convert between Godot Image and png data.
Switched to libpng 1.6 simplified API for ease of maintenance.
Implemented ImageLoaderPNG and ResourceSaverPNG in terms of
PNGDriverCommon functions.
Travis, switched to builtin libpng (thus builtin freetype and zlib also)
so we can build on Xenial.
2019-06-19 11:05:58 +01:00
Rémi Verschelde
99acec63f1 bullet: Sync with current upstream master branch
This updates our local copy to commit 5ec8339b6fc491e3f09a34a4516e82787f053fcc.
We need a recent master commit for some new features that we use in Godot
(see #25543 and #28909).

To avoid warnings generated by Bullet headers included in our own module,
we include those headers with -isystem on GCC and Clang.

Fixes #29503.
2019-06-11 13:19:42 +02:00
Rémi Verschelde
d52b70fb5e SCons: Always use env.Prepend for CPPPATH
Include paths are processed from left to right, so we use Prepend to
ensure that paths to bundled thirdparty files will have precedence over
system paths (e.g. `/usr/include` should have lowest priority).
2019-04-30 13:12:06 +02:00
Michele Valente
c0fcd55f96 fix builds made with Clang on some Linux distros
This is the same as #23542 (Fix binaries incorrectly detected as shared
libraries on some linux distros) but for Clang. It should be fine with
Clang 4 or higher.
2019-04-26 15:50:06 +02:00
Rémi Verschelde
7e65a11bcf
Merge pull request #28402 from Valentactive/add-thinlto-support-x11
Add option to use ThinLTO
2019-04-25 22:23:31 +02:00
Michele Valente
51f9042a5b add option to use ThinLTO
This adds ThinLTO support when using Clang and the LLD Linker, it's
turned off by
default.
For now only support for Linux added as ThinLTO support on other
platforms may still be buggy.
2019-04-25 19:20:12 +02:00
Rémi Verschelde
c2a669a9f0 SCons: Review uses of CCFLAGS, CXXFLAGS and CPPFLAGS
Many contributors (me included) did not fully understand what CCFLAGS,
CXXFLAGS and CPPFLAGS refer to exactly, and were thus not using them
in the way they are intended to be.

As per the SCons manual: https://www.scons.org/doc/HTML/scons-user/apa.html

- CCFLAGS: General options that are passed to the C and C++ compilers.
- CFLAGS: General options that are passed to the C compiler (C only;
  not C++).
- CXXFLAGS: General options that are passed to the C++ compiler. By
  default, this includes the value of $CCFLAGS, so that setting
  $CCFLAGS affects both C and C++ compilation.
- CPPFLAGS: User-specified C preprocessor options. These will be
  included in any command that uses the C preprocessor, including not
  just compilation of C and C++ source files [...], but also [...]
  Fortran [...] and [...] assembly language source file[s].

TL;DR: Compiler options go to CCFLAGS, unless they must be restricted
to either C (CFLAGS) or C++ (CXXFLAGS). Preprocessor defines go to
CPPFLAGS.
2019-04-24 16:57:58 +02:00
Hein-Pieter van Braam
a76d59cba9
Merge pull request #27208 from Calinou/add-lld-linker
Add support for linking using LLD on X11
2019-04-23 06:11:48 +03:00
Hendrikto
49a81308c0 Remove unused imports 2019-04-06 18:05:05 +02:00
Rémi Verschelde
e4a96164b6 SCons: add methods.using_clang to check used compiler
Also rename `use_gcc` to `using_gcc` to make it clear that it returns
a config but does not alter it.
2019-04-05 12:51:15 +02:00
Rémi Verschelde
44f1b390a3 SCons: Fix python3 compat for builtin_bullet=no 2019-04-03 11:25:01 +02:00
Pedro J. Estébanez
9c3ddf05cb Revert accidental commits
This reverts commit fb37284c02.
This reverts commit 4db0f51b9a.
2019-03-20 21:43:55 +01:00
Pedro J. Estébanez
fb37284c02 Create class for shared memory blocks [wip] 2019-03-20 20:44:43 +01:00
Hugo Locurcio
fd7f253649
Add support for linking using LLD on X11
LLD is often faster than GNU ld and gold, resulting in a better
development experience.

This closes #15364.
2019-03-18 16:52:00 +01:00
Rémi Verschelde
c77c4ef3b1 SCons: Reduce spam from x11:can_build
When cross-compiling for non-X11 on Linux, it used to be quite spammy.
Now it will only print errors if you miss more than just pkg-config and x11.
2019-03-02 10:39:20 +01:00
marxin
0d2a105e6b Come up with use_gcc.
Add new method. Fix wrong version condition for -fpie.
2019-02-23 09:17:11 +01:00
marxin
8d51618949 Add -Wshadow=local to warnings and fix reported issues.
Fixes #25316.
2019-02-20 19:44:12 +01:00
marxin
e558773e21 Rename sanitizer option names.
Make the sanitizer names more explicit (use_ubsan, use_asan, use_lsan).
Comment has been adjusted to include GCC as supported compiler for these
and exclude -fno-omit-frame-pointer option (should not cause any
problems).
2019-01-21 08:10:15 +01:00
Hein-Pieter van Braam
e5b335d367 Don't use -ffast-math or other unsafe math optimizations
Godot supports many different compilers and for production releases we
have to support 3 currently: GCC8, Clang6, and MSVC2017. These compilers
all do slightly different things with -ffast-math and it is causing
issues now. See #24841, #24540, #10758, #10070. And probably other
complaints about physics differences between release and release_debug
builds.

I've done some performance comparisons on Linux x86_64. All tests are
ran 20 times.

Bunnymark: (higher is better)
(bunnies)    min    max  stdev average
fast-math   7332   7597    71     7432
this pr     7379   7779   108     7621 (102%)

FPBench (gdscript port http://fpbench.org/) (lower is better)
(ms)
fast-math  15441  16127   192    15764
this pr    15671  16855   326    16001  (99%)

Float_add (adding floats in a tight loop) (lower is better)
(sec)
fast-math   5.49   5.78  0.07     5.65
this pr     5.65   5.90  0.06     5.76  (98%)

Float_div (dividing floats in a tight loop) (lower is better)
(sec)
fast-math  11.70  12.36  0.18    11.99
this pr    11.92  12.32  0.12    12.12  (99%)

Float_mul (multiplying floats in a tight loop) (lower is better)
(sec)
fast-math  11.72  12.17  0.12    11.93
this pr    12.01  12.62  0.17    12.26  (97%)

I have also looked at FPS numbers for tps-demo, 3d platformer, 2d
platformer, and sponza and could not find any measurable difference.

I believe that given the issues and oft-reported (physics) glitches on
release builds I believe that the couple of percent of tight-loop
floating point performance regression is well worth it.

This fixes #24540 and fixes #24841
2019-01-09 02:06:13 +01:00
Cosmic Chip Socket
cf124b1415 Use XInput2 RawMotion to generate MouseMotion events
The current system for capturing the mouse and generating motion events on X11
has issues with inaccurate and lopsided input. This is because both
XQueryPointer and XWarpPointer work in terms of integer coordinates when the
underlying X11 input driver may be tracking the mouse using subpixel
coordinates. When warping the pointer, the fractional part of the pointer
position is discarded.

To work around this issue, the fix uses raw motion events from XInput 2. These
events report relative motion and are not affected by pointer warping.
Additionally, this means Godot is able to detect motion at a higher resolution
under X11. Because this is raw mouse input, it is not affected by the user's
pointer speed and acceleration settings. This is the same system as SDL2 uses
for its relative motion.

Multitouch input on X requires XInput 2.2. Raw motion events require
XInput 2.0. Since 2.0 is old enough, this is now the minimum requirement to
use Godot on X.
2018-12-14 23:51:20 +01:00
Ibrahn Sahir
4c90a66e74 Fix gcc version check when running scons in python 3. 2018-11-14 12:25:50 +00:00
Marcelo Fernandez
8705c01f5a Fix compile recent compile issues with gcc 5.5 2018-11-12 10:24:44 -03:00