1. petsc
  2. PETSc
  3. buildsystem-3.3

Commits

Jed Brown  committed d5ea201

Add --with-visibility

  • Participants
  • Parent commits a186cf5
  • Branches default

Comments (0)

Files changed (2)

File config/compilerOptions.py

View file
     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'])

File config/types.py

View file
   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