merge bitcoin#30074: use ENV flags in get_arch

This commit is contained in:
Kittywhiskers Van Gogh 2024-11-04 14:51:40 +00:00
parent decd420ca1
commit 5585e7a849
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD
2 changed files with 7 additions and 9 deletions

View File

@ -28,22 +28,24 @@ def clean_files(source, executable):
os.remove(source)
os.remove(executable)
def call_security_check(cc, source, executable, options):
def env_flags() -> List[str]:
# This should behave the same as AC_TRY_LINK, so arrange well-known flags
# in the same order as autoconf would.
#
# See the definitions for ac_link in autoconf's lib/autoconf/c.m4 file for
# reference.
env_flags: List[str] = []
flags: List[str] = []
for var in ['CFLAGS', 'CPPFLAGS', 'LDFLAGS']:
env_flags += filter(None, os.environ.get(var, '').split(' '))
flags += filter(None, os.environ.get(var, '').split(' '))
return flags
subprocess.run([*cc,source,'-o',executable] + env_flags + options, check=True)
def call_security_check(cc, source, executable, options):
subprocess.run([*cc,source,'-o',executable] + env_flags() + options, check=True)
p = subprocess.run(['./contrib/devtools/security-check.py',executable], stdout=subprocess.PIPE, universal_newlines=True)
return (p.returncode, p.stdout.rstrip())
def get_arch(cc, source, executable):
subprocess.run([*cc, source, '-o', executable], check=True)
subprocess.run([*cc, source, '-o', executable] + env_flags(), check=True)
binary = lief.parse(executable)
arch = binary.abstract.header.architecture
os.remove(executable)

View File

@ -28,10 +28,6 @@ def call_symbol_check(cc: List[str], source, executable, options):
os.remove(executable)
return (p.returncode, p.stdout.rstrip())
def get_machine(cc: List[str]):
p = subprocess.run([*cc,'-dumpmachine'], stdout=subprocess.PIPE, universal_newlines=True)
return p.stdout.rstrip()
class TestSymbolChecks(unittest.TestCase):
def test_ELF(self):
source = 'test1.c'