I'm seeing this from a clean build from scratch on : gcc -DHAVE_CONFIG_H -I. -I../../binutils-gdb/binutils -I. -I../../binutils-gdb/binutils -I../bfd -I../../binutils-gdb/binutils/../bfd -I../../binutils-gdb/binutils/../include -DLOCALEDIR="\"/home/hftsai/Workshops/test_gdb/build.install/share/locale\"" -Dbin_dummy_emulation=bin_vanilla_emulation -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -I../../binutils-gdb/binutils/../zlib -g -O2 -MT arparse.o -MD -MP -MF .deps/arparse.Tpo -c -o arparse.o `test -f arparse.c || echo ../../binutils-gdb/binutils/`arparse.c In file included from ../../binutils-gdb/binutils/../include/alloca-conf.h:16:0, from ../../binutils-gdb/binutils/sysdep.h:23, from ../../binutils-gdb/binutils/arparse.y:29: ./config.h:7:4: error: #error config.h must be #included before system headers # error config.h must be #included before system headers ^~~~~ After checking with some possible duplicates, I guess this issue is not related to bfd.h. Repository: git://sourceware.org/git/binutils-gdb.git Commit: 899016d4 gdb-9.1-release OS: Ubuntu 18.04.1 gcc version: 7.4.0 configuration parameters: --disable-werror
Please attach a file with the results of running gcc -DHAVE_CONFIG_H -I. -I../../binutils-gdb/binutils -I. -I../../binutils-gdb/binutils -I../bfd -I../../binutils-gdb/binutils/../bfd -I../../binutils-gdb/binutils/../include -DLOCALEDIR="\"/home/hftsai/Workshops/test_gdb/build.install/share/locale\"" -Dbin_dummy_emulation=bin_vanilla_emulation -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -I../../binutils-gdb/binutils/../zlib -g -O2 -E -dD `test -f arparse.c || echo ../../binutils-gdb/binutils/`arparse.c ie. the command line you posted without "-MT arparse.o -MD -MP -MF .deps/arparse.Tpo -c -o arparse.o" and adding -E -dD.
I was able to get pass this issue by installing libipt-dev and libbabeltrace-dev packages, and cannot reproduce the same issue on my machine anymore. No idea what changes I made resolved this issue.