Jed Brown avatar Jed Brown committed d5ea201

Add --with-visibility

Comments (0)

Files changed (2)

config/compilerOptions.py

     if config.setCompilers.Configure.isGNU(compiler) or config.setCompilers.Configure.isClang(compiler):
       if bopt == '':
         flags.extend(['-Wall', '-Wwrite-strings', '-Wno-strict-aliasing','-Wno-unknown-pragmas'])
+        if self.framework.argDB['with-visibility']:
+          flags.extend(['-fvisibility=hidden'])
       elif bopt == 'g':
         if self.framework.argDB['with-gcov']:
           flags.extend(['-fprofile-arcs', '-ftest-coverage'])
     if config.setCompilers.Configure.isGNU(compiler) or config.setCompilers.Configure.isClang(compiler):
       if bopt == '':
         flags.extend(['-Wall', '-Wwrite-strings', '-Wno-strict-aliasing','-Wno-unknown-pragmas'])
+        if self.framework.argDB['with-visibility']:
+          flags.extend(['-fvisibility=hidden'])
       elif bopt in ['g']:
         if self.framework.argDB['with-gcov']:
           flags.extend(['-fprofile-arcs', '-ftest-coverage'])
   def setupHelp(self, help):
     import nargs
     help.addArgument('Types', '-known-endian=<big or little>', nargs.Arg(None, None, 'Are bytes stored in big or little endian?'))
+    help.addArgument('Visibility', '-with-visibility=<bool>', nargs.Arg(None, 0, 'Use compiler visibility flags to limit symbol visibility'))
     return
 
   def setupDependencies(self, framework):
     self.addDefine('BITS_PER_BYTE', bits)
     return
 
+
+  def checkVisibility(self):
+    if self.framework.argDB['with-visibility']:
+      if not self.checkCompile('','__attribute__((visibility ("default"))) int foo(void);'):
+        raise RuntimeError('Cannot use visibility attributes')
+      self.addDefine('USE_VISIBILITY',1)
+
   def configure(self):
     self.executeTest(self.check__int64)
     self.executeTest(self.checkSizeTypes)
     self.executeTest(self.checkEndian)
     map(lambda type: self.executeTest(self.checkSizeof, type), ['char','void *', 'short', 'int', 'long', 'long long', 'float', 'double', 'size_t'])
     self.executeTest(self.checkBitsPerByte)
-
-
+    self.executeTest(self.checkVisibility)
     return
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.