Commit Graph

180 Commits

Author SHA1 Message Date
David Anderson
6e2c5a66b3 Remove use of the Dep API.
This is going away.
2020-08-24 20:48:57 -07:00
David Anderson
9acf2b5cda Use Python 3.8 on the Windows buildbot. 2020-08-19 00:39:54 -07:00
David Anderson
785c6aa1cf Update to AMBuild 2.2.
This is a pretty big diff because SourceMod had lots of multi-arch
workarounds that can now go away. I've also changed 'x64' to 'x86_64' in
many places since this is how AMBuild normalizes it, and it's far too
late to pick the shorter string, so we might as well suck it up.

The --target-archs parameter has been replaced with --targets. It works
the same way.

The default behavior for SDK inclusion is now "present" instead of
"all" since this lowers the burden of storing many SDKs. Official builds
will still be made with --sdks=all.
2020-08-18 23:09:43 -07:00
peace-maker
510bd261f8
core: Add Insurgency support for amd64 Windows (#1295)
* Add basic Insurgency support on Windows x64

This allows SourceMod to load on x64 Insurgency. There are still a lot of variable truncation warnings that have to be dealt with.

* Fix 32bit builds

* Compile MySQL extension as well

The hack for __iob_func being removed from the core runtime, but required by the old mysql we're building against can be simplified a lot due to the `_ReturnAddress` intrinsic available since MSVC 2015.

* Don't include the offset we want to extract in the signature
2020-08-06 19:53:06 -07:00
David Anderson
e5ddbd9886 Introduce a pbproxy library to solve macOS linker issues.
On SDKs which use protobufs, the engine has objects compiled against a specific
version of protobuf. Normally this is fine, we take care on Linux to use the
same C++ ABI. On macOS however, we use libc++ to enable C++11 functionality,
whereas the protobuf library has been compiled with libstc++. These ABIs are
not compatible.

To address the problem, we introduce PbHandle. PbHandle is a wrapper around
protobuf::Message with two added pieces of state: whether or not the handle
"owns" the message (and can free it in its destructor), and whether or not
the handle was created by the engine (private) or created by SourceMod
(local).

Whenever we transfer a protobuf::Message pointer to SourceMod, we must take
care to convert it to a Local version first. Whenever we transfer a protobuf
pointer to the engine, we must convert it to a Private handle.

For platforms with no ABI differences (almost all of them), the handle is a
no-op. The private and local localities are compatible and no translation
takes place.

On macOS, CS:GO does require translation. SourceMod loads a tiny shim
library that contains a copy of the protobuf sources compiled against the
game's ABI. It then provides serialization and deserialization methods.
SourceMod must not interact with the game's protobuf objects without first
going through this proxy library.

Note that PbHandle is not quite like unique_ptr. It can be converted into a
PbHandle that does not destroy the underlying object. This is mainly because
UserMessages.cpp has rather complex state, so it is useful to track locality
without destroying an object. An unowned PbHandle must not outlive the
owning PbHandle.
2020-05-30 22:13:07 -07:00
David Anderson
d525b466ec Use C++11 for macOS and CS:GO. 2020-05-30 22:13:07 -07:00
David Anderson
49669f6585 Revert "Fix linking on Linux."
This reverts commit acf8782786.
2020-05-26 20:04:55 -07:00
David Anderson
acf8782786 Fix linking on Linux. 2020-05-25 21:35:50 -07:00
David Anderson
c9f574c27b Fix mac build. 2020-05-20 22:50:41 -07:00
David Anderson
7a3e4054c7 Enable exception handling in C++ code.
It turns out this was already enabled on MSVC (due to /EHsc), but let's
enable it on other platforms as well.

Exception handling comes with a huge caveat: SourceMod and SourcePawn
are not exception safe. Not only do they predate usable STL (C++11),
they often predate C++03, and sometimes even C++ itself. There are many
places we do not use RAII, or where we accumulate state in a way that
cannot be interrupted.

By enabling exceptions, we are NOT inviting general try/catch. We are
still assuming that a `throw` anywhere within SourceMod will ultimately
result in a crash.

However, as we enable more and more STL, we are losing the ability to
gracefully handle constructor failures and malloc failures. So try-catch
is now enabled. It should only be used in the narrowest of
circumstances:

 - When an exception can be thrown by a library call, and
 - There is no way "a priori" to tell if an exception will be thrown
(for example, std::bad_alloc or std::system_error), and
 - Handling the exception is meaningful.

Generally malloc failures should not be considered meaningful. Once
memory is exhausted, the program will crash or be OOM-killed, so there's
no point in handling the failure. However, cases where the allocation
amount is variable may be meaningful to handle. A simple example would
be CDataPack, where if a plugin leaks entries, it's better to handle
this gracefully given that vector growth is geometric. Another example
might be reads of a massive file or network request into a buffer.

These cases should be rare, given that memory pressure is usually
fatal to srcds anyway. But if you've decided to handle an exception,
the try-catch block should be as narrow as possible. For example,
the following is erroneous:

    ke::Maybe<SomeGiganticThing> object;
    try {
        object.init();
    } catch (const std::bad_alloc&) {
    }

`ke::Maybe` is not threadsafe, and this can leak. Basically, do as
little as possible in try blocks, and use them sparingly, because
they're very difficult to audit.

We are also not inviting use of `throw`, as auditing it is even more
complex than try/catch. It is better to abort(), or use boolean
returns and two-stage object initialization.
2020-05-19 12:21:57 -07:00
David Anderson
ff018a9a5d Improve Travis coverage.
Our official builds use clang-3.4 (for macOS) and clang-3.8 for Linux.
Linux uses libstdc++-4.9. Make sure these two compilers are being tested
and that libstdc++-4.9 is being used for STL.

Add a macOS builder to get coverage there. This will use a newer
clang than we actually use, but as opposed to the linux builder will
test the platform-specific bits.

Finally, use the latest GCC and clang versions from a bionic image, so
we have some coverage of a popular distribution.
2020-05-13 19:09:20 -07:00
David Anderson
f76cb94511 Pare down ThreadSupport and remove ancient thread code.
This patch removes almost all of the existing platform-specific
ThreadSupport code, as well as code derived from it. It is now
implemented on top of C++11 threads and is much simpler.

This is the first inclusion of STL in SourceMod. Mac and Windows are
allowed to dynamically link to their respective implementations. On
Linux, libstdc++ is statically linked, except in the cases where it was
already dynamically linked (csgo, blade).

IEventSignal has been retained because sourcemod-curl-extension relies
on it. As written, it is impossible to use as a condition variable,
because the caller does not have access to the underlying mutex. There
is no way to make this API safe or non-racy, so extensions relying on
it should switch to C++11 threads.

ThreadWorker is now pared down and does not interact or inherit from
BaseWorker in any way. Basic functionality has been tested. Since it is
not used anywhere in SourceMod, or seemingly in any repository on
GitHub, it's unclear whether it should even exist. But it has been
tested in this patch.

This change bumps the minimum macOS version to OS X 10.7, and the
minimum C++ standard level to C++14.
2020-05-13 00:35:29 -07:00
David Anderson
87cc42d348 Fix build failures with clang 10. 2020-05-12 23:04:55 -07:00
Asher Baker
6465bd83a4 Update for latest Blade Symphony SDK 2020-03-11 22:36:25 +00:00
Asher Baker
bff8585411
Add an option to build against no SDKs (#1201) 2020-03-04 21:52:07 +00:00
Asher Baker
6a307bfcee
Restore the frame pointer on Linux (#1200)
Looks like the default here changed when we upgraded the Linux build server.

This is causing issues when debugging crash dumps.
2020-03-04 21:43:13 +00:00
Nicholas Hastings
1000d419fc Throw configuration error on unsupported compilers (#1029) 2019-11-15 16:40:39 -08:00
David Anderson
7ab3a3cfd9 Update SourcePawn to master.
This turns on the new expression parser by default.
2019-10-28 21:19:22 -07:00
Asher Baker
8ce99e0540 Link pthread library for Linux binaries 2019-07-24 14:47:13 +01:00
Headline
2164f5191e
Fix GCC 9 Builds (#1024) 2019-05-28 17:57:40 -07:00
Asher Baker
1ca4517f46 Revert "Remove arch loops from build scripts. (#889)"
This reverts commit 7ed329c11f.
2018-10-04 17:59:40 +00:00
David Anderson
7ed329c11f
Remove arch loops from build scripts. (#889)
This simplifies non-sdk build scripts by removing their loops over SM.archs. Instead the top-level
build script will re-evaluate them for each architecture.
2018-09-30 09:59:28 -07:00
peace-maker
9cc518e408 Fix MySQL extension build using vs2015 (#824)
MySQL defines its own timespec_t. Official mysql builds are built using VS2013, so you still need to compile the client library yourself to be able to link it, but this change makes the dbi extension compatible with future versions already.
2018-06-05 09:29:11 -04:00
Nicholas Hastings
4637cf9221
Use MySQL 5.5 for MySQL extension. (#786) 2018-03-20 17:12:30 -04:00
Scott Ehlert
ce1a4dcac0
64-bit support for CSGO on Linux and macOS (#705) 2017-12-20 01:56:23 -06:00
Nicholas Hastings
4007ec8cf8 Temp fix for load issues on Linux. 2017-12-05 20:44:53 -05:00
Nicholas Hastings
95afe72307
Separate out DOI build. (#718) 2017-11-03 15:45:16 -04:00
Scott Ehlert
27b69559a3 Really fix macOS build. 2017-10-26 20:38:25 -05:00
Kyle Sanderson
65bf85fcbe (Re-)Add support for gcc and clang3.9, 4.0, and 5.0. 2017-10-09 16:53:19 -07:00
Scott Ehlert
bbdecceb4b Switch to AMBuild 2.1 API. (#694) 2017-10-02 07:18:57 -05:00
peace-maker
8840ce905d Update to latest SourcePawn (#639) 2017-07-18 12:48:39 +01:00
Nicholas Hastings
ad3588d0aa Use newer MM:S api for Ep1/Original engine. (#548)
* Use newer MM:S api for Ep1/Original engine.

* Remove doubled FILENAME_1_6_EP1 define.
2017-01-11 21:25:00 -05:00
Nicholas Hastings
7fda6e412a Don't build for CS:GO on Mac anymore. (Game is 64-bit-only there now). 2016-10-13 20:54:54 -04:00
Nicholas Hastings
f668b3fe6c 🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍 2016-06-11 12:43:04 -04:00
Nicholas Hastings
f12924458f Merge branch 'vs2015' 2016-06-11 12:14:12 -04:00
Nicholas Hastings
40f2512317 Remove support for Source 1 Dota 2. (#496) 2016-04-26 23:18:47 -04:00
Nicholas Hastings
29a5daab98 Allow support for running on filesystems that use 64-bit inodes on Linux. (#502)
Most supported games don't even support this case, but at least CS:GO does. WIthout
this fix, some filesystem calls can fail, or in the case of readdir, fail to return all/any files.
This was first observed when using an XFS-formatted volume on CentOS 7 x64.
2016-04-26 23:17:36 -04:00
Nicholas Hastings
416abd81a1 Add support for compiling with VS2015. 2016-03-30 08:56:27 -04:00
Nicholas Hastings
3c24ce4d7b Change --exclude-libs to be for Linux only. Apple's linker does not support it. 2016-01-09 11:50:13 -05:00
Nicholas Hastings
05c7bd4be9 Don't export (all) symbols from included static lib on Linux/Mac. 2016-01-09 10:26:12 -05:00
Nicholas Hastings
529d7e2659 Fix Insurgency build on Linux for SDK changes. 2015-10-27 18:17:26 -07:00
David Anderson
6c5ab80418 Refactor and cleanup the AMBuildScript a bit. 2015-10-08 14:55:53 -07:00
Nicholas Hastings
292df5010f Stop building Source 1 Dota 2 build. 2015-09-18 15:36:46 -04:00
David Anderson
e30b57cb4a Update build scripts for new AMTL folder structure. 2015-08-26 15:54:55 -04:00
Nicholas Hastings
4dd641287d Fix typo in last commit. 2015-08-15 11:56:36 -04:00
Nicholas Hastings
199d1b8eeb Fix Mac build. 2015-08-14 22:00:43 -04:00
Nicholas Hastings
620cb405b1 Fix build on Clang 3.6. 2015-08-14 08:25:40 -04:00
Nicholas Hastings
4152e05dcd Fix indentation. 2015-05-12 06:21:32 -07:00
Nicholas Hastings
b3efc36487 Link libm in all bin, not just engine-specific ones.
This fixes the "undefined symbol: floorf" error that some people were getting in sourcemod.logic.so.
2015-05-11 18:59:12 -04:00
Nicholas Hastings
64f9aedebc Add basic support for Black Mesa.
(Basically a copy of SDK 2013's support, but against BMS SDK).
2015-05-06 21:12:13 -04:00