davidmalcolm / gcc-python-plugin

GCC plugin that embeds CPython inside the compiler
GNU General Public License v3.0
197 stars 58 forks source link

Makefile fails to build on gcc8.2.1 on centos7 (__STDC_FORMAT_MACROS not defined) #180

Closed roadk1ll closed 4 years ago

roadk1ll commented 4 years ago

What the error looks like: /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/plugin/include/wide-int.h: In member function 'void generic_wide_int::dump() const': /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/plugin/include/hwint.h:113:38: error: expected ')' before 'PRIx64'

define HOST_WIDE_INT_PRINT_HEX "%#" PRIx64

                                  ^~~~~~

Sorry not proficient with this, but my work around for anyone else who is encountering same... If there is a better way - please let me know...

diff -up ./Makefile.original ./Makefile --- ./Makefile.original +++ ./Makefile \@@ -116,10 +116,15 @@ PLUGIN_DIR := $(PLUGIN_NAME) # (Eventually it will be moved to its own project) LIBGCC_C_API_SO := gcc-c-api/libgcc-c-api.so

-CPPFLAGS+= -I$(GCCPLUGINS_DIR)/include -I$(GCCPLUGINS_DIR)/include/c-family -I. $(PYTHON_INCLUDES) +CUSTOMINCLUDES=-include/usr/include/inttypes.h +CUSTOMDEFINES=-D__STDC_FORMAT_MACROS + +AUTO_CPPFLAGS+= -I$(GCCPLUGINS_DIR)/include -I$(GCCPLUGINS_DIR)/include/c-family -I. $(PYTHON_INCLUDES) +CPPFLAGS+= $(CUSTOMINCLUDES) -I$(GCCPLUGINS_DIR)/include -I$(GCCPLUGINS_DIR)/include/c-family -I. $(PYTHON_INCLUDES) $(CUSTOMDEFINES) # Allow user to pick optimization, choose whether warnings are fatal, # and choose debugging information level. -CFLAGS?=-O2 -Werror -g +#CFLAGS?=-O2 -Werror -g +CFLAGS?=-O2 -g # Force these settings CFLAGS+= -fPIC -fno-strict-aliasing -Wall LIBS+= $(PYTHON_LIBS) \@@ -186,7 +191,7 @@ autogenerated-config.h: generate-config- $(PYTHON) $< -o $@ --gcc="$(CC)" --plugindir="$(GCCPLUGINS_DIR)"

autogenerated-%.txt: %.txt.in - $(CPP) $(CPPFLAGS) -x c-header $^ -o $@ + $(CPP) $(AUTO_CPPFLAGS) -x c-header $^ -o $@

# autogenerated-EXTRA_CFLAGS.txt is a byproduct of making # autogenerated-config.h:

##################################################### My system... cat /etc/redhat-release -> CentOS Linux release 7.2.1511 (Core)

yum install list | grep gcc devtoolset-8-gcc.x86_64 8.2.1-3.el7 @core9_1/$releasever devtoolset-8-gcc-c++.x86_64 8.2.1-3.el7 @core9_1/$releasever devtoolset-8-gcc-gdb-plugin.x86_64 8.2.1-3.el7 @core9_1/$releasever devtoolset-8-gcc-plugin-devel.x86_64

gcc -v Using built-in specs. COLLECT_GCC=/opt/rh/devtoolset-8/root/usr/bin/gcc COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper Target: x86_64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-8/root/usr --mandir=/opt/rh/devtoolset-8/root/usr/share/man --infodir=/opt/rh/devtoolset-8/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-8.2.1-20180905/obj-x86_64-redhat-linux/isl-install --disable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux Thread model: posix gcc version 8.2.1 20180905 (Red Hat 8.2.1-3) (GCC)

roadk1ll commented 4 years ago

Rebuilt in another environment and it compiles like butter...This is not an issue with this package - my apologies.

roadk1ll commented 4 years ago

This is glibc2.17 (centos 6/7) _The C99 standard suggests that C++ implementations should not define the above limit, constant, or format macros unless the macros STDC_LIMIT_MACROS, STDC_CONSTANT_MACROS or STDC_FORMAT_MACROS (respectively) are defined before including the relevant C header (stdint.h or inttypes.h). This recommendation was not adopted by any C++ standard and was removed in C11. However, some implementations (such as glibc 2.17) try to apply this rule, and it may be necessary to define the STDC macros; C++ compilers may try to work around this by automatically defining them in some circumstances._