Bug 1631211 - In configure, pass extra compiler flags after source path. r=dmajor

When running e.g. check_symbols with extra flags like when checking
for vpx_codec_dec_init_ver when building against system libvpx, in some
configurations, the test can fail when the library flags (-l) appear
before the source file path.

The reason is that in some configurations, the compiler passes
--as-needed to the linker before both the flags and the object file
path, and the object file path is in the same position as the source
file path was. With --as-needed, -l flags are dropped if the library
wasn't needed for any of the linked code that appears *before* the flag.
So linking with `--as-needed -lfoo foo.o`, is equivalent to linking with
`foo.o` only in practice, while `--as-needed foo.o -lfoo` is equivalent
to `foo.o -lfoo`.

Differential Revision: https://phabricator.services.mozilla.com/D71456
This commit is contained in:
Mike Hommey 2020-04-20 14:07:15 +00:00
Родитель 6b3fcc326b
Коммит 4bf8161c8f
1 изменённых файлов: 1 добавлений и 1 удалений

Просмотреть файл

@ -221,7 +221,7 @@ def try_invoke_compiler(compiler, language, source, flags=None, onerror=None):
os.write(fd, ensure_binary(source))
os.close(fd)
cmd = compiler + list(flags) + [path]
cmd = compiler + [path] + list(flags)
kwargs = {'onerror': onerror}
return check_cmd_output(*cmd, **kwargs)
finally: