Skip to content

Commit 695d801

Browse files
committed
Merge bitcoin/bitcoin#30074: contrib: use ENV flags in get_arch
b59a027 contrib: drop dead get_machine from test sym check (fanquake) e6aba46 contrib: use env_flags in get_arch (fanquake) Pull request description: This isn't an issue right now (because the get_arch check is simple), but becomes one as soon as we want to use `lld` for linking, and need LDFLAGS (otherwise we call `ld` and fail, see it's usage in #21778). So I've split this out for review. It also makes sense to use the same flags for all compilation in these checks. Also drops some dead code in test-symbol-check. ACKs for top commit: TheCharlatan: ACK b59a027 Tree-SHA512: d8afc4144815369aae63cf6dc6e983af46f208c7043d6ea5c9c811152649c256a8e67eb6864ea9d385d87b6b049fece07710a84b90da325da7fc3f05efcaacd6
2 parents f5fc319 + b59a027 commit 695d801

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

contrib/devtools/test-security-check.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,24 @@ def clean_files(source, executable):
2727
os.remove(source)
2828
os.remove(executable)
2929

30-
def call_security_check(cc: str, source: str, executable: str, options) -> tuple:
30+
def env_flags() -> list[str]:
3131
# This should behave the same as AC_TRY_LINK, so arrange well-known flags
3232
# in the same order as autoconf would.
3333
#
3434
# See the definitions for ac_link in autoconf's lib/autoconf/c.m4 file for
3535
# reference.
36-
env_flags: list[str] = []
36+
flags: list[str] = []
3737
for var in ['CFLAGS', 'CPPFLAGS', 'LDFLAGS']:
38-
env_flags += filter(None, os.environ.get(var, '').split(' '))
38+
flags += filter(None, os.environ.get(var, '').split(' '))
39+
return flags
3940

40-
subprocess.run([*cc,source,'-o',executable] + env_flags + options, check=True)
41+
def call_security_check(cc: str, source: str, executable: str, options) -> tuple:
42+
subprocess.run([*cc,source,'-o',executable] + env_flags() + options, check=True)
4143
p = subprocess.run([os.path.join(os.path.dirname(__file__), 'security-check.py'), executable], stdout=subprocess.PIPE, text=True)
4244
return (p.returncode, p.stdout.rstrip())
4345

4446
def get_arch(cc, source, executable):
45-
subprocess.run([*cc, source, '-o', executable], check=True)
47+
subprocess.run([*cc, source, '-o', executable] + env_flags(), check=True)
4648
binary = lief.parse(executable)
4749
arch = binary.abstract.header.architecture
4850
os.remove(executable)

contrib/devtools/test-symbol-check.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ def call_symbol_check(cc: list[str], source, executable, options):
2727
os.remove(executable)
2828
return (p.returncode, p.stdout.rstrip())
2929

30-
def get_machine(cc: list[str]):
31-
p = subprocess.run([*cc,'-dumpmachine'], stdout=subprocess.PIPE, text=True)
32-
return p.stdout.rstrip()
33-
3430
class TestSymbolChecks(unittest.TestCase):
3531
def test_ELF(self):
3632
source = 'test1.c'

0 commit comments

Comments
 (0)