Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
build: fix gcc 3.x build
Detect gcc version, -fvisibility is a gcc 4.x switch.
  • Loading branch information
bnoordhuis committed Oct 25, 2011
1 parent d15b88a commit cb6cd92
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
20 changes: 20 additions & 0 deletions 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)
5 changes: 4 additions & 1 deletion common.gypi
Expand Up @@ -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', ],
Expand All @@ -125,7 +128,7 @@
[ 'OS=="linux"', {
'cflags': [ '-ansi' ],
}],
[ 'visibility=="hidden"', {
[ 'visibility=="hidden" and gcc_version >= "4.0.0"', {
'cflags': [ '-fvisibility=hidden' ],
}],
],
Expand Down

0 comments on commit cb6cd92

Please sign in to comment.