Skip to content

Commit 52fe091

Browse files
committed
gcc-with-cpychecker: Add CC_FOR_CPYCHECKER
gcc-with-cpychecker does not use CC to find gcc, in order to avoid forkbombing when setting CC=gcc-with-cpychecker, and instead uses a hardcoded 'gcc'. This means that when we want to use a specific gcc, we either needs to edit gcc-with-cpychecker to adjust the filename, or use PATH settings to pick up gcc (which may mean having to map somehow f.i. 'gcc-7' to 'gcc'). Add handling of CC_FOR_CPYCHECKER in gcc-with-cpychecker, to be able to easily specify the gcc to be used.
1 parent ef78bdc commit 52fe091

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ plugin: autogenerated-config.h $(PLUGIN_DSO)
132132
# When running the plugin from a working copy, use LD_LIBARY_PATH=gcc-c-api
133133
# so that the plugin can find its libgcc-c-api.so there
134134
#
135-
INVOCATION_ENV_VARS := LD_LIBRARY_PATH=gcc-c-api CC=$(CC)
135+
INVOCATION_ENV_VARS := CC_FOR_CPYCHECKER=$(CC) LD_LIBRARY_PATH=gcc-c-api CC=$(CC)
136136

137137
# When installing, both the plugin and libgcc-c-api.so will be installed to
138138
# $(GCCPLUGINS_DIR), so we give the plugin an RPATH of $(GCCPLUGINS_DIR)

gcc-with-cpychecker

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,14 @@ dictstr += ', "maxtrans":%i' % ns.maxtrans
7474
dictstr += ', "dump_json":%i' % ns.dump_json
7575
cmd = 'from libcpychecker import main; main(**{%s})' % dictstr
7676

77-
# (Do not look up CC in the environment, to avoid forkbombing
78-
# when setting CC=gcc-with-cpychecker)
79-
args = ['gcc',
77+
# Do not use CC in the environment, to avoid forkbombing when setting
78+
# CC=gcc-with-cpychecker. Instead, use CC_FOR_CPYCHECKER.
79+
if 'CC_FOR_CPYCHECKER' in os.environ:
80+
gcc = os.environ['CC_FOR_CPYCHECKER']
81+
else:
82+
gcc = 'gcc'
83+
84+
args = [gcc,
8085
('-fplugin=%s' % PLUGIN),
8186
('-fplugin-arg-python-command=%s' % cmd)]
8287
args += other_args # (the args we didn't consume)

0 commit comments

Comments
 (0)