Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 814200 | Differences between
and this patch

Collapse All | Expand All

(-)a/scripts/gcc-plugin.sh (-66 lines)
Lines 1-66 Link Here
1
#!/bin/sh
2
# SPDX-License-Identifier: GPL-2.0
3
srctree=$(dirname "$0")
4
5
SHOW_ERROR=
6
if [ "$1" = "--show-error" ] ; then
7
	SHOW_ERROR=1
8
	shift || true
9
fi
10
11
gccplugins_dir=$($3 -print-file-name=plugin)
12
plugincc=$($1 -E -x c++ - -o /dev/null -I"${srctree}"/gcc-plugins -I"${gccplugins_dir}"/include 2>&1 <<EOF
13
#include "gcc-common.h"
14
#if BUILDING_GCC_VERSION >= 4008 || defined(ENABLE_BUILD_WITH_CXX)
15
#warning $2 CXX
16
#else
17
#warning $1 CC
18
#endif
19
EOF
20
)
21
22
if [ $? -ne 0 ]
23
then
24
	if [ -n "$SHOW_ERROR" ] ; then
25
		echo "${plugincc}" >&2
26
	fi
27
	exit 1
28
fi
29
30
case "$plugincc" in
31
	*"$1 CC"*)
32
		echo "$1"
33
		exit 0
34
		;;
35
36
	*"$2 CXX"*)
37
		# the c++ compiler needs another test, see below
38
		;;
39
40
	*)
41
		exit 1
42
		;;
43
esac
44
45
# we need a c++ compiler that supports the designated initializer GNU extension
46
plugincc=$($2 -c -x c++ -std=gnu++98 - -fsyntax-only -I"${srctree}"/gcc-plugins -I"${gccplugins_dir}"/include 2>&1 <<EOF
47
#include "gcc-common.h"
48
class test {
49
public:
50
	int test;
51
} test = {
52
	.test = 1
53
};
54
EOF
55
)
56
57
if [ $? -eq 0 ]
58
then
59
	echo "$2"
60
	exit 0
61
fi
62
63
if [ -n "$SHOW_ERROR" ] ; then
64
	echo "${plugincc}" >&2
65
fi
66
exit 1
(-)a/scripts/gcc-plugins/Kconfig (-9 / +2 lines)
Lines 1-12 Link Here
1
# SPDX-License-Identifier: GPL-2.0-only
1
# SPDX-License-Identifier: GPL-2.0-only
2
preferred-plugin-hostcc := $(if-success,[ $(gcc-version) -ge 40800 ],$(HOSTCXX),$(HOSTCC))
3
4
config PLUGIN_HOSTCC
5
	string
6
	default "$(shell,$(srctree)/scripts/gcc-plugin.sh "$(preferred-plugin-hostcc)" "$(HOSTCXX)" "$(CC)")" if CC_IS_GCC
7
	help
8
	  Host compiler used to build GCC plugins.  This can be $(HOSTCXX),
9
	  $(HOSTCC), or a null string if GCC plugin is unsupported.
10
2
11
config HAVE_GCC_PLUGINS
3
config HAVE_GCC_PLUGINS
12
	bool
4
	bool
Lines 17-23 config HAVE_GCC_PLUGINS Link Here
17
menuconfig GCC_PLUGINS
9
menuconfig GCC_PLUGINS
18
	bool "GCC plugins"
10
	bool "GCC plugins"
19
	depends on HAVE_GCC_PLUGINS
11
	depends on HAVE_GCC_PLUGINS
20
	depends on PLUGIN_HOSTCC != ""
12
	depends on CC_IS_GCC
13
	depends on $(success,test -e $(shell,$(CC) -print-file-name=plugin)/include/plugin-version.h)
21
	default y
14
	default y
22
	help
15
	help
23
	  GCC plugins are loadable modules that provide extra features to the
16
	  GCC plugins are loadable modules that provide extra features to the
(-)a/scripts/gcc-plugins/Makefile (-14 / +6 lines)
Lines 1-19 Link Here
1
# SPDX-License-Identifier: GPL-2.0
1
# SPDX-License-Identifier: GPL-2.0
2
PLUGINCC := $(CONFIG_PLUGIN_HOSTCC:"%"=%)
3
GCC_PLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
2
GCC_PLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
4
3
5
ifeq ($(PLUGINCC),$(HOSTCC))
4
HOSTLIBS := hostcxxlibs
6
  HOSTLIBS := hostlibs
5
HOST_EXTRACXXFLAGS += -I$(GCC_PLUGINS_DIR)/include -I$(src) -std=gnu++11 -fno-rtti
7
  HOST_EXTRACFLAGS += -I$(GCC_PLUGINS_DIR)/include -I$(src) -std=gnu99 -ggdb
6
HOST_EXTRACXXFLAGS += -fno-exceptions -fasynchronous-unwind-tables -ggdb
8
  export HOST_EXTRACFLAGS
7
HOST_EXTRACXXFLAGS += -Wno-narrowing -Wno-unused-variable
9
else
8
HOST_EXTRACXXFLAGS += -Wno-format-diag
10
  HOSTLIBS := hostcxxlibs
9
export HOST_EXTRACXXFLAGS
11
  HOST_EXTRACXXFLAGS += -I$(GCC_PLUGINS_DIR)/include -I$(src) -std=gnu++98 -fno-rtti
12
  HOST_EXTRACXXFLAGS += -fno-exceptions -fasynchronous-unwind-tables -ggdb
13
  HOST_EXTRACXXFLAGS += -Wno-narrowing -Wno-unused-variable
14
  HOST_EXTRACXXFLAGS += -Wno-format-diag
15
  export HOST_EXTRACXXFLAGS
16
endif
17
10
18
$(obj)/randomize_layout_plugin.o: $(objtree)/$(obj)/randomize_layout_seed.h
11
$(obj)/randomize_layout_plugin.o: $(objtree)/$(obj)/randomize_layout_seed.h
19
quiet_cmd_create_randomize_layout_seed = GENSEED $@
12
quiet_cmd_create_randomize_layout_seed = GENSEED $@
20
- 

Return to bug 814200