Skip to content
Browse files

build: fix gcc 3.x build

Detect gcc version, -fvisibility is a gcc 4.x switch.
  • Loading branch information...
1 parent d15b88a commit cb6cd92305e1326883afacc40dff6b4d72009310 @bnoordhuis bnoordhuis committed Oct 25, 2011
Showing with 24 additions and 1 deletion.
  1. +20 −0 build/gcc_version.py
  2. +4 −1 common.gypi
View
20 build/gcc_version.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+
+import os
+import re
+import subprocess
+import sys
+
+
+def DoMain(*args):
+ cc = os.environ.get('CC', 'gcc')
+ stdin, stderr = os.pipe()
+ subprocess.call([cc, '-v'], stderr=stderr)
+ output = os.read(stdin, 4096)
+ match = re.search("\ngcc version (\d+\.\d+\.\d+)", output)
+ if match:
+ print(match.group(1))
+
+
+if __name__ == '__main__':
+ DoMain(*sys.argv)
View
5 common.gypi
@@ -114,6 +114,9 @@
],
}],
[ 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', {
+ 'variables': {
+ 'gcc_version%': '<!(python build/gcc_version.py)>)',
+ },
'cflags': [ '-Wall', '-pthread', ],
'cflags_cc': [ '-fno-rtti', '-fno-exceptions' ],
'ldflags': [ '-pthread', ],
@@ -125,7 +128,7 @@
[ 'OS=="linux"', {
'cflags': [ '-ansi' ],
}],
- [ 'visibility=="hidden"', {
+ [ 'visibility=="hidden" and gcc_version >= "4.0.0"', {
'cflags': [ '-fvisibility=hidden' ],
}],
],

0 comments on commit cb6cd92

Please sign in to comment.
Something went wrong with that request. Please try again.