@@ -116,8 +116,10 @@ CPPFLAGS+= -I$(GCCPLUGINS_DIR)/include -I$(GCCPLUGINS_DIR)/include/c-family -I.
116
116
# Allow user to pick optimization, choose whether warnings are fatal,
117
117
# and choose debugging information level.
118
118
CFLAGS? =-O2 -Werror -g
119
+ CXXFLAGS? =-O2 -Werror -g
119
120
# Force these settings
120
121
CFLAGS+ = -fPIC -fno-strict-aliasing -Wall
122
+ CXXFLAGS+ = -fPIC -fno-strict-aliasing -Wall
121
123
LIBS+ = $(PYTHON_LIBS )
122
124
ifneq "$(PLUGIN_PYTHONPATH ) " ""
123
125
CPPFLAGS+ = -DPLUGIN_PYTHONPATH='"$(PLUGIN_PYTHONPATH ) "'
@@ -136,23 +138,39 @@ plugin: autogenerated-config.h $(PLUGIN_DSO)
136
138
#
137
139
INVOCATION_ENV_VARS := LD_LIBRARY_PATH=gcc-c-api CC="$(TARGET_GCC ) "
138
140
141
+ , := ,
142
+
143
+ define run-cc
144
+ set -- $1; \
145
+ read gcc_cxx < "autogenerated-EXTRA_CFLAGS.txt"; \
146
+ if [ "$$gcc_cxx" = '-x c' ]; then \
147
+ $(if $2,$2,$(CC ) $(CFLAGS ) ) "$$@ "; \
148
+ elif [ "$$gcc_cxx" = '-x c++' ]; then \
149
+ $(if $3,$3,$(CXX ) $(CXXFLAGS ) ) "$$@ "; \
150
+ else \
151
+ false; \
152
+ fi
153
+ endef
154
+
139
155
# When installing, both the plugin and libgcc-c-api.so will be installed to
140
156
# $(GCCPLUGINS_DIR), so we give the plugin an RPATH of $(GCCPLUGINS_DIR)
141
157
# so that it finds the libgcc-c-api.so there (to support the case of having
142
158
# multiple GCCs installed)
143
159
#
144
160
$(PLUGIN_DSO ) : $(PLUGIN_OBJECT_FILES ) $(LIBGCC_C_API_SO )
145
- $(CC ) \
146
- $(CPPFLAGS ) $(CFLAGS ) $(LDFLAGS ) \
161
+ $(call run-cc, \
147
162
-shared \
148
163
$(PLUGIN_OBJECT_FILES ) \
149
- -o $@ \
150
164
$(LIBS ) \
151
- -lgcc-c-api -Lgcc-c-api -Wl,-rpath=$(GCCPLUGINS_DIR )
165
+ $(OUTPUT_OPTION ) \
166
+ -lgcc-c-api -Lgcc-c-api -Wl$(, ) -rpath=$(GCCPLUGINS_DIR ) , \
167
+ $(LINK.c ) , \
168
+ $(LINK.cpp ) \
169
+ )
152
170
153
171
.PHONY : gcc-c-api/phony-stamp-gcc-api
154
172
gcc-c-api/phony-stamp-gcc-api : autogenerated-EXTRA_CFLAGS.txt
155
- $(MAKE ) -C gcc-c-api libgcc-c-api.so CC=" $( CC) " TARGET_GCC=" $( TARGET_GCC) "
173
+ $(MAKE ) -C gcc-c-api libgcc-c-api.so CC=" $( CC) " CXX= " $( CXX ) " TARGET_GCC=" $( TARGET_GCC) "
156
174
157
175
$(LIBGCC_C_API_SO ) : gcc-c-api/phony-stamp-gcc-api
158
176
@@ -161,7 +179,7 @@ $(PLUGIN_OBJECT_GENERATED_FILES): CPPFLAGS+= $(if $(srcdir),-I$(srcdir))
161
179
# This is the standard .c->.o recipe, but it needs to be stated
162
180
# explicitly to support the case that $(srcdir) is not blank.
163
181
$(PLUGIN_OBJECT_SOURCE_FILES ) $(PLUGIN_OBJECT_GENERATED_FILES ) : % .o: $(srcdir ) % .c autogenerated-config.h $(srcdir ) gcc-python.h $(LIBGCC_C_API_SO ) autogenerated-EXTRA_CFLAGS.txt
164
- $(COMPILE.c ) $( shell cat autogenerated-EXTRA_CFLAGS.txt) $( OUTPUT_OPTION ) $<
182
+ $(call run-cc, $< $( OUTPUT_OPTION ) , $( COMPILE.c ), $( COMPILE.cpp ) )
165
183
166
184
# Use a long variable name to avoid unwanted matches. Add an explicit
167
185
# -x c since gcc requires a language specifier when processing stdin.
0 commit comments