From 2d4e3a6d254800be6e032f1279dd7f8a6c23b941 Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Sun, 20 Apr 2014 14:52:50 -0500 Subject: [PATCH] Link amxxpc with static libstdc++ on Linux. --- AMBuildScript | 19 +++++++++++++++++++ compiler/amxxpc/AMBuilder | 1 + 2 files changed, 20 insertions(+) diff --git a/AMBuildScript b/AMBuildScript index aa9d91e3..00c80a98 100644 --- a/AMBuildScript +++ b/AMBuildScript @@ -1,5 +1,7 @@ # vim: set sts=2 ts=8 sw=2 tw=99 et ft=python : import os +import subprocess +import locale class AMXXConfig(object): def __init__(self): @@ -13,6 +15,7 @@ class AMXXConfig(object): self.mysql_path = None self.generated_headers = None self.csx_app = None + self.stdcxx_path = None def detectProductVersion(self): builder.AddConfigureFile('product.version') @@ -93,6 +96,19 @@ class AMXXConfig(object): if not self.mysql_path: raise Exception('Could not find MySQL! Try passing --mysql to configure.py.') + # Returns list of lines of output from the compiler + @staticmethod + def invokeCompiler(args): + if builder.compiler: + p = subprocess.Popen(builder.compiler.argv + args, stdout=subprocess.PIPE) + output = p.communicate()[0] + if hasattr(output,'encoding') and output.encoding is not None: + encoding = output.encoding + else: + encoding = locale.getpreferredencoding() + return output.decode(encoding, 'replace').split('\n') + return None + def configure(self): builder.AddConfigureFile('pushbuild.txt') @@ -199,6 +215,9 @@ class AMXXConfig(object): cfg.postlink += ['-static-libgcc'] elif cxx.name == 'clang': cfg.postlink += ['-lgcc_eh'] + if cxx.behavior == 'gcc': + self.stdcxx_path = self.invokeCompiler(['-m32', '-print-file-name=' + 'libstdc++.a'])[0] + print(self.stdcxx_path) elif builder.target_platform == 'mac': cfg.defines += ['OSX', '_OSX', 'POSIX'] cfg.cflags += ['-mmacosx-version-min=10.5'] diff --git a/compiler/amxxpc/AMBuilder b/compiler/amxxpc/AMBuilder index b154773b..270e262c 100644 --- a/compiler/amxxpc/AMBuilder +++ b/compiler/amxxpc/AMBuilder @@ -14,6 +14,7 @@ if builder.target_platform == 'linux': binary.compiler.postlink += [ '-ldl', binary.Dep('libz.a'), + binary.Dep(AMXX.stdcxx_path), ] elif builder.target_platform == 'mac': binary.compiler.postlink += [binary.Dep('libz-darwin.a')]