File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -2480,8 +2480,20 @@ def doConfigure(myenv):
24802480 context .Result (ret )
24812481 return ret
24822482
2483+ def CheckForGlibcDefinesFortify (context ):
2484+ test_body = """
2485+ #ifndef _FORTIFY_SOURCE
2486+ #error
2487+ #endif
2488+ """
2489+ context .Message ('Checking for predefined _FORTIFY_SOURCE...' )
2490+ ret = context .TryCompile (textwrap .dedent (test_body ), ".c" )
2491+ context .Result (ret )
2492+ return ret
2493+
24832494 conf = Configure (myenv , help = False , custom_tests = {
24842495 'CheckForFortify' : CheckForGlibcKnownToSupportFortify ,
2496+ 'CheckForFortifyDefined' : CheckForGlibcDefinesFortify ,
24852497 })
24862498
24872499 # Fortify only possibly makes sense on POSIX systems, and we know that clang is not a valid
@@ -2490,6 +2502,10 @@ def doConfigure(myenv):
24902502 # http://lists.llvm.org/pipermail/cfe-dev/2015-November/045852.html
24912503 #
24922504 if env .TargetOSIs ('posix' ) and not env .ToolchainIs ('clang' ) and conf .CheckForFortify ():
2505+ if conf .CheckForFortifyDefined ():
2506+ conf .env .Prepend (
2507+ CPPFLAGS = '-U_FORTIFY_SOURCE'
2508+ )
24932509 conf .env .Append (
24942510 CPPDEFINES = [
24952511 ('_FORTIFY_SOURCE' , 2 ),
You can’t perform that action at this time.
0 commit comments