Author: brane Date: Sun Jun 29 16:08:41 2025 New Revision: 1926860 URL: http://svn.apache.org/viewvc?rev=1926860&view=rev Log: Detect ELF build targets in SCons dynamically at configure time, just like the CMake build does. Otherwise there are just too many to list, and we do want to limit symbol visibility in the shared libraries wherever we can (or know how to).
* SConstruct: Detect if the build target is ELF by compiling a C program and looking for the ELF magic number in the resulting binary. * build/exports.py (ExportGenerator._guess_target): Don't guess about ELF. Modified: serf/trunk/SConstruct serf/trunk/build/exports.py Modified: serf/trunk/SConstruct URL: http://svn.apache.org/viewvc/serf/trunk/SConstruct?rev=1926860&r1=1926859&r2=1926860&view=diff ============================================================================== --- serf/trunk/SConstruct (original) +++ serf/trunk/SConstruct Sun Jun 29 16:08:41 2025 @@ -226,6 +226,24 @@ env.Append(BUILDERS = { # Export symbol generator (for Windows DLL, Mach-O and ELF) export_generator = build.exports.ExportGenerator() if export_generator.target is None: + # Detect if the build target is an ELF platform the the + # generator doesn't know about. + sys.stdout.write("Checking if the build target is ELF ...") + conf = Configure(env) # No custom tests, we want a clean environment. + if (conf.TryLink('int main(void) { return 0; }', '.c')): + header = conf.lastTarget.get_contents()[:4] + if header == b'\x7fELF': # This is the ELF magic number. + print(" yes") + elf = build.exports.TARGET_ELF + export_generator = build.exports.ExportGenerator(elf) + else: + print(" no") + else: + print(" failed") + conf.Finish() + +# Now try again... +if export_generator.target is None: # Nothing to do on this platform export_generator = None else: Modified: serf/trunk/build/exports.py URL: http://svn.apache.org/viewvc/serf/trunk/build/exports.py?rev=1926860&r1=1926859&r2=1926860&view=diff ============================================================================== --- serf/trunk/build/exports.py (original) +++ serf/trunk/build/exports.py Sun Jun 29 16:08:41 2025 @@ -108,14 +108,15 @@ class ExportGenerator(object): return TARGET_WINDLL if sys.platform == 'darwin': return TARGET_MACHO - if sys.platform.startswith('linux'): - return TARGET_ELF - if (sys.platform.startswith('freebsd') and int(sys.platform[7:]) >= 4): - return TARGET_ELF - if (sys.platform.startswith('openbsd') and int(sys.platform[7:]) >= 6): - return TARGET_ELF - if (sys.platform.startswith('netbsd') and int(sys.platform[6:]) >= 2): - return TARGET_ELF + # FIXME: SConstruct checks for ELF, these should probably be removed. + # if sys.platform.startswith('linux'): + # return TARGET_ELF + # if (sys.platform.startswith('freebsd') and int(sys.platform[7:]) >= 4): + # return TARGET_ELF + # if (sys.platform.startswith('openbsd') and int(sys.platform[7:]) >= 6): + # return TARGET_ELF + # if (sys.platform.startswith('netbsd') and int(sys.platform[6:]) >= 2): + # return TARGET_ELF return None def _gen_win_def(self, stream, symbols):