aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2017-03-09 14:52:56 +0530
committerJussi Pakkanen <jpakkane@gmail.com>2017-03-10 11:33:26 -0500
commit853634a48da025c59eef70161dba0d150833f60d (patch)
treec6284598882e7eea210f282ba68f9b3bf7d2bdd4 /mesonbuild/compilers.py
parent1713aef364560c9de922991716880e4db32f88a5 (diff)
downloadmeson-853634a48da025c59eef70161dba0d150833f60d.zip
meson-853634a48da025c59eef70161dba0d150833f60d.tar.gz
meson-853634a48da025c59eef70161dba0d150833f60d.tar.bz2
Add UNIX large file support via compiler always-args
On 32-bit Linux and BSD, all libcs support this. Musl always enables it, and UClibc behaves like Glibc unless it's built without large file support (which is a terrible idea). http://wiki.musl-libc.org/wiki/FAQ#Q:_do_i_need_to_define_LARGEFILE64_SOURCE_to_get_64bit_off_t_.3F https://git.uclibc.org/uClibc/tree/include/features.h#n326 macOS now only ships 64-bit, so this is irrelevant there. 32-bit Windows and older versions of Bionic do not have transparent large file support and you must use lseek64, etc there, so this won't affect those. Newer Bionic versions behave like Glibc in theory. https://msdn.microsoft.com/en-us/library/1yee101t.aspx http://code.google.com/p/android/issues/detail?id=64613 Includes a linuxlike test for this. Closes https://github.com/mesonbuild/meson/issues/1032
Diffstat (limited to 'mesonbuild/compilers.py')
-rw-r--r--mesonbuild/compilers.py37
1 files changed, 33 insertions, 4 deletions
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py
index 8c2bb92..8ea161d 100644
--- a/mesonbuild/compilers.py
+++ b/mesonbuild/compilers.py
@@ -709,7 +709,10 @@ class CCompiler(Compiler):
return True # When compiling static libraries, so yes.
def get_always_args(self):
- return []
+ '''
+ Args that are always-on for all C compilers other than MSVC
+ '''
+ return ['-pipe'] + get_largefile_args(self)
def get_linker_debug_crt_args(self):
"""
@@ -2025,6 +2028,7 @@ class VisualStudioCCompiler(CCompiler):
'3': ['/W4']}
self.base_options = ['b_pch'] # FIXME add lto, pgo and the like
+ # Override CCompiler.get_always_args
def get_always_args(self):
return self.always_args
@@ -2263,6 +2267,34 @@ def get_gcc_soname_args(gcc_type, prefix, shlib_name, suffix, path, soversion, i
else:
raise RuntimeError('Not implemented yet.')
+def get_compiler_is_linuxlike(compiler):
+ if (getattr(compiler, 'gcc_type', None) == GCC_STANDARD) or \
+ (getattr(compiler, 'clang_type', None) == CLANG_STANDARD) or \
+ (getattr(compiler, 'icc_type', None) == ICC_STANDARD):
+ return True
+ return False
+
+def get_largefile_args(compiler):
+ '''
+ Enable transparent large-file-support for 32-bit UNIX systems
+ '''
+ if get_compiler_is_linuxlike(compiler):
+ # Enable large-file support unconditionally on all platforms other
+ # than macOS and Windows. macOS is now 64-bit-only so it doesn't
+ # need anything special, and Windows doesn't have automatic LFS.
+ # You must use the 64-bit counterparts explicitly.
+ # glibc, musl, and uclibc, and all BSD libcs support this. On Android,
+ # support for transparent LFS is available depending on the version of
+ # Bionic: https://github.com/android/platform_bionic#32-bit-abi-bugs
+ # https://code.google.com/p/android/issues/detail?id=64613
+ #
+ # If this breaks your code, fix it! It's been 20+ years!
+ return ['-D_FILE_OFFSET_BITS=64']
+ # We don't enable -D_LARGEFILE64_SOURCE since that enables
+ # transitionary features and must be enabled by programs that use
+ # those features explicitly.
+ return []
+
class GnuCompiler:
# Functionality that is common to all GNU family compilers.
@@ -2311,9 +2343,6 @@ class GnuCompiler:
return apple_buildtype_linker_args[buildtype]
return gnulike_buildtype_linker_args[buildtype]
- def get_always_args(self):
- return ['-pipe']
-
def get_pch_suffix(self):
return 'gch'