Skip to content

Commit

Permalink
merge bitcoin#30074: use ENV flags in get_arch
Browse files Browse the repository at this point in the history
  • Loading branch information
kwvg committed Nov 7, 2024
1 parent 809c9a2 commit f610bf9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
12 changes: 7 additions & 5 deletions contrib/devtools/test-security-check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions contrib/devtools/test-symbol-check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit f610bf9

Please sign in to comment.