Skip to content

Commit

Permalink
Remove linkerlike args from compile checks. Closes #4542.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpakkane committed Nov 26, 2018
1 parent 37ffff0 commit b57f330
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion mesonbuild/compilers/c.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,13 @@ def _get_compiler_check_args(self, env, extra_args, dependencies, mode='compile'
args += env.coredata.get_external_preprocess_args(self.language)
elif mode == 'compile':
# Add CFLAGS/CXXFLAGS/OBJCFLAGS/OBJCXXFLAGS from the env
args += env.coredata.get_external_args(self.language)
sys_args = env.coredata.get_external_args(self.language)
# Apparently it is a thing to inject linker flags _both_
# via CFLAGS and LDFLAGS. Even though the latter are
# also used during linking. These flags can break
# argument checks. Thanks, Autotools.
cleaned_sys_args = self.remove_linkerlike_args(sys_args)
args += cleaned_sys_args
elif mode == 'link':
# Add LDFLAGS from the env
args += env.coredata.get_external_link_args(self.language)
Expand All @@ -436,6 +442,9 @@ def _get_compiler_check_args(self, env, extra_args, dependencies, mode='compile'
args += extra_args
return args

def remove_linkerlike_args(self, args):
return [x for x in args if not x.startswith('-Wl')]

def compiles(self, code, env, *, extra_args=None, dependencies=None, mode='compile'):
with self._build_wrapper(code, env, extra_args, dependencies, mode) as p:
return p.returncode == 0
Expand Down

0 comments on commit b57f330

Please sign in to comment.