aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/environment.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2016-08-11 16:27:31 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2016-08-12 15:34:59 +0530
commita5e01fa15522c33dfbdfee4cec43227026184c84 (patch)
tree5fa2fe6f9f77417d83d2b398a2bf69cb30e6bdc5 /mesonbuild/environment.py
parent5b7e4ac1f69c88c6bf1d46e92a41e60ea666c753 (diff)
downloadmeson-a5e01fa15522c33dfbdfee4cec43227026184c84.zip
meson-a5e01fa15522c33dfbdfee4cec43227026184c84.tar.gz
meson-a5e01fa15522c33dfbdfee4cec43227026184c84.tar.bz2
Only append compile flags to the link flags when appropriate
We should only append the compiler flags to the link flags when the compiler is used as a wrapper around the linker during the link process
Diffstat (limited to 'mesonbuild/environment.py')
-rw-r--r--mesonbuild/environment.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index 4ee7393..16af0d1 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -701,7 +701,7 @@ class Environment():
return self.coredata.get_builtin_option('datadir')
-def get_args_from_envvars(lang):
+def get_args_from_envvars(lang, compiler_is_linker):
"""
@lang: Language to fetch environment flags for
@@ -727,15 +727,21 @@ def get_args_from_envvars(lang):
link_flags = os.environ.get('LDFLAGS', '')
log_var('LDFLAGS', link_flags)
link_flags = link_flags.split()
+ if compiler_is_linker:
+ # When the compiler is used as a wrapper around the linker (such as
+ # with GCC and Clang), the compile flags can be needed while linking
+ # too. This is also what Autotools does. However, we don't want to do
+ # this when the linker is stand-alone such as with MSVC C/C++, etc.
+ link_flags = compile_flags + link_flags
# Pre-processof rlags (not for fortran)
preproc_flags = ''
if lang in ('c', 'cpp', 'objc', 'objcpp'):
preproc_flags = os.environ.get('CPPFLAGS', '')
log_var('CPPFLAGS', preproc_flags)
- preproc_flags = preproc_flags.split()
+ compile_flags += preproc_flags.split()
- return (compile_flags + preproc_flags, link_flags + compile_flags)
+ return (compile_flags, link_flags)
class CrossBuildInfo():
def __init__(self, filename):