Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: fix building outside source directory #209

Closed
wants to merge 1 commit into from
Closed

BUG: fix building outside source directory #209

wants to merge 1 commit into from

Conversation

andreas-schwab
Copy link

@andreas-schwab andreas-schwab commented Feb 24, 2020

Move -I${top_builddir}/include to toplevel so that it is available in all
subdirs. This is needed to find <seccomp.h> in the build directory, since
it is now a generated file.

Signed-off-by: Andreas Schwab schwab@suse.de

@pcmoore
Copy link
Member

pcmoore commented Feb 26, 2020

Hi @andreas-schwab, the include/seccomp.h file is generated during configure time, not build time:

# ./configure
checking for a BSD-compatible install... /bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking how to create a pax tar archive... gnutar
checking for gcc... gcc
...
config.status: creating include/seccomp.h
...

... can you describe the problem you were seeing which required this patch?

@andreas-schwab
Copy link
Author

configure time is build time.

@pcmoore
Copy link
Member

pcmoore commented Feb 26, 2020

configure time is build time.

/me rolls eyes

As I asked previously, can you describe the problem you are seeing which required this patch?
We have been generating include/seccomp.h.in since the v2.1.0 release, so it would be helpful to understand what has changed in your build that is causing this to fail; unless it has been broken for the past (almost) seven years.

@andreas-schwab
Copy link
Author

There is no seccomp.h in ${top_srcdir}/include.

@pcmoore
Copy link
Member

pcmoore commented Feb 26, 2020

One more time: please explain your build system so we can understand how/why this is happening. I would like to try to reproduce this.

@andreas-schwab
Copy link
Author

There is nothing that creates the file in there.

@pcmoore
Copy link
Member

pcmoore commented Feb 26, 2020

Seriously @andreas-schwab please explain what build system you are using and how we can reproduce the build failure you are seeing. The code has been this way for almost seven years and this is the first we have heard of a failure due to this; I just want to understand what your build system is doing that is so unique.

If you are not able to share the information on your build system, or supply a reproducer, I am not inclined to merge this PR.

@andreas-schwab
Copy link
Author

There is nothing special, just a normal build:

Making all in tools
CC scmp_sys_resolver.o
../../libseccomp/tools/scmp_sys_resolver.c:29:10: fatal error: seccomp.h: No such file or directory
29 | #include <seccomp.h>
| ^~~~~~~~~~~
compilation terminated.
make[2]: *** [Makefile:524: scmp_sys_resolver.o] Error 1
make[1]: *** [Makefile:514: all-recursive] Error 1
make: *** [Makefile:423: all] Error 2

@pcmoore
Copy link
Member

pcmoore commented Feb 26, 2020

Can you show us your entire build process, starting from doing a git clone? This may seem a bit extreme, but as I said previously, this doesn't seem to be broken for most people so I'm trying to figure out what is happening in your case that is unique.

As an example, here is what I see with the current master branch:

# ./autogen.sh
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, 'build-aux'.
libtoolize: copying file 'build-aux/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: copying file 'm4/libtool.m4'
libtoolize: copying file 'm4/ltoptions.m4'
libtoolize: copying file 'm4/ltsugar.m4'
libtoolize: copying file 'm4/ltversion.m4'
libtoolize: copying file 'm4/lt~obsolete.m4'
configure.ac:52: installing 'build-aux/compile'
configure.ac:47: installing 'build-aux/missing'
src/Makefile.am: installing 'build-aux/depcomp'
# ./configure --prefix=/tmp/seccomp --enable-python
checking for a BSD-compatible install... /bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking how to create a pax tar archive... gnutar
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of gcc... gcc3
checking for ar... ar
checking the archiver (ar) interface... ar
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /bin/ld
checking if the linker (/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /bin/nm -B
checking the name lister (/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking whether make supports nested variables... (cached) yes
checking for linux/seccomp.h... yes
checking for cython3... cython3
checking cython version... 0.29.15
checking for a Python interpreter with version >= 3... python
checking for python... /bin/python
checking for python version... 3.8
checking for python platform... linux
checking for python script directory... ${prefix}/lib/python3.8/site-packages
checking for python extension module directory... ${exec_prefix}/lib/python3.8/site-packages
checking for cov-build... yes
checking whether to build with code coverage support... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating libseccomp.pc
config.status: creating include/seccomp.h
config.status: creating Makefile
config.status: creating include/Makefile
config.status: creating src/Makefile
config.status: creating src/python/Makefile
config.status: creating tools/Makefile
config.status: creating tests/Makefile
config.status: creating doc/Makefile
config.status: creating configure.h
config.status: configure.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands
# make
make --quiet --no-print-directory all-recursive
Making all in include
Making all in src
Making all in .
  CC       libseccomp_la-api.lo
  CC       libseccomp_la-system.lo
  CC       libseccomp_la-helper.lo
  CC       libseccomp_la-gen_pfc.lo
  CC       libseccomp_la-gen_bpf.lo
  CC       libseccomp_la-hash.lo
  CC       libseccomp_la-db.lo
  CC       libseccomp_la-arch.lo
  CC       libseccomp_la-arch-x86.lo
  CC       libseccomp_la-arch-x86-syscalls.lo
  CC       libseccomp_la-arch-x86_64.lo
  CC       libseccomp_la-arch-x86_64-syscalls.lo
  CC       libseccomp_la-arch-x32.lo
  CC       libseccomp_la-arch-x32-syscalls.lo
  CC       libseccomp_la-arch-arm.lo
  CC       libseccomp_la-arch-arm-syscalls.lo
  CC       libseccomp_la-arch-aarch64.lo
  CC       libseccomp_la-arch-aarch64-syscalls.lo
  CC       libseccomp_la-arch-mips.lo
  CC       libseccomp_la-arch-mips-syscalls.lo
  CC       libseccomp_la-arch-mips64.lo
  CC       libseccomp_la-arch-mips64-syscalls.lo
  CC       libseccomp_la-arch-mips64n32.lo
  CC       libseccomp_la-arch-mips64n32-syscalls.lo
  CC       libseccomp_la-arch-parisc.lo
  CC       libseccomp_la-arch-parisc64.lo
  CC       libseccomp_la-arch-parisc-syscalls.lo
  CC       libseccomp_la-arch-ppc.lo
  CC       libseccomp_la-arch-ppc-syscalls.lo
  CC       libseccomp_la-arch-ppc64.lo
  CC       libseccomp_la-arch-ppc64-syscalls.lo
  CC       libseccomp_la-arch-riscv64.lo
  CC       libseccomp_la-arch-riscv64-syscalls.lo
  CC       libseccomp_la-arch-s390.lo
  CC       libseccomp_la-arch-s390-syscalls.lo
  CC       libseccomp_la-arch-s390x.lo
  CC       libseccomp_la-arch-s390x-syscalls.lo
  CCLD     libseccomp.la
Making all in python
  PYTHON   build
Making all in tools
  CC       scmp_sys_resolver.o
  CCLD     scmp_sys_resolver
  CC       scmp_arch_detect.o
  CCLD     scmp_arch_detect
  CC       scmp_bpf_disasm.o
  CC       util.lo
  CCLD     util.la
  CCLD     scmp_bpf_disasm
  CC       scmp_bpf_sim.o
  CCLD     scmp_bpf_sim
  CC       scmp_api_level.o
  CCLD     scmp_api_level
Making all in tests
Making all in doc
#

@andreas-schwab
Copy link
Author

$ make
make --quiet --no-print-directory all-recursive
Making all in include
Making all in src
Making all in .
CC libseccomp_la-system.lo
CC libseccomp_la-gen_pfc.lo
CC libseccomp_la-gen_bpf.lo
CC libseccomp_la-db.lo
CC libseccomp_la-arch.lo
CC libseccomp_la-arch-x86.lo
CC libseccomp_la-arch-x86-syscalls.lo
CC libseccomp_la-arch-x86_64.lo
CC libseccomp_la-arch-x86_64-syscalls.lo
CC libseccomp_la-arch-x32.lo
CC libseccomp_la-arch-x32-syscalls.lo
CC libseccomp_la-arch-arm.lo
CC libseccomp_la-arch-arm-syscalls.lo
CC libseccomp_la-arch-aarch64.lo
CC libseccomp_la-arch-aarch64-syscalls.lo
CC libseccomp_la-arch-mips.lo
CC libseccomp_la-arch-mips-syscalls.lo
CC libseccomp_la-arch-mips64.lo
CC libseccomp_la-arch-mips64-syscalls.lo
CC libseccomp_la-arch-mips64n32.lo
CC libseccomp_la-arch-mips64n32-syscalls.lo
CC libseccomp_la-arch-parisc.lo
CC libseccomp_la-arch-parisc64.lo
CC libseccomp_la-arch-parisc-syscalls.lo
CC libseccomp_la-arch-ppc.lo
CC libseccomp_la-arch-ppc-syscalls.lo
CC libseccomp_la-arch-ppc64.lo
CC libseccomp_la-arch-ppc64-syscalls.lo
CC libseccomp_la-arch-riscv64.lo
CC libseccomp_la-arch-riscv64-syscalls.lo
CC libseccomp_la-arch-s390.lo
CC libseccomp_la-arch-s390-syscalls.lo
CC libseccomp_la-arch-s390x.lo
CC libseccomp_la-arch-s390x-syscalls.lo
CCLD libseccomp.la
Making all in tools
CC scmp_sys_resolver.o
../../libseccomp/tools/scmp_sys_resolver.c:29:10: fatal error: seccomp.h: No such file or directory
29 | #include <seccomp.h>
| ^~~~~~~~~~~
compilation terminated.
make[2]: *** [Makefile:524: scmp_sys_resolver.o] Error 1
make[1]: *** [Makefile:514: all-recursive] Error 1
make: *** [Makefile:423: all] Error 2

@pcmoore
Copy link
Member

pcmoore commented Feb 26, 2020

Can you show us your entire build process, starting from doing a git clone?

Please do the following and show us the output from all of the commands:

  1. Clone the libseccomp repository
# git clone https://github.com/seccomp/libseccomp.git libseccomp-test
  1. Change into the newly cloned local repository
# cd libseccomp-test
  1. Generate the autotools files
# ./autogen.sh
  1. Run "configure"
# ./configure
  1. Do the build
# make

@andreas-schwab
Copy link
Author

configure: loading site script /usr/share/site/riscv64-suse-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking how to create a pax tar archive... gnutar
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of gcc... gcc3
checking for ar... ar
checking the archiver (ar) interface... ar
checking build system type... riscv64-unknown-linux-gnu
checking host system type... riscv64-unknown-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/riscv64-suse-linux/bin/ld
checking if the linker (/usr/riscv64-suse-linux/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert riscv64-unknown-linux-gnu file names to riscv64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert riscv64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/riscv64-suse-linux/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @file support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /usr/bin/dd
checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1
checking for mt... mt
checking if mt is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/riscv64-suse-linux/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
checking whether make supports nested variables... (cached) yes
checking for linux/seccomp.h... yes
checking for cython3... no
checking for cython... no
checking for cov-build... no
checking whether to build with code coverage support... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating libseccomp.pc
config.status: creating include/seccomp.h
config.status: creating Makefile
config.status: creating include/Makefile
config.status: creating src/Makefile
config.status: creating src/python/Makefile
config.status: creating tools/Makefile
config.status: creating tests/Makefile
config.status: creating doc/Makefile
config.status: creating configure.h
config.status: configure.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands

make --quiet --no-print-directory all-recursive
Making all in include
Making all in src
Making all in .
CC libseccomp_la-api.lo
CC libseccomp_la-system.lo
CC libseccomp_la-helper.lo
CC libseccomp_la-gen_pfc.lo
CC libseccomp_la-gen_bpf.lo
CC libseccomp_la-hash.lo
CC libseccomp_la-db.lo
CC libseccomp_la-arch.lo
CC libseccomp_la-arch-x86.lo
CC libseccomp_la-arch-x86-syscalls.lo
CC libseccomp_la-arch-x86_64.lo
CC libseccomp_la-arch-x86_64-syscalls.lo
CC libseccomp_la-arch-x32.lo
CC libseccomp_la-arch-x32-syscalls.lo
CC libseccomp_la-arch-arm.lo
CC libseccomp_la-arch-arm-syscalls.lo
CC libseccomp_la-arch-aarch64.lo
CC libseccomp_la-arch-aarch64-syscalls.lo
CC libseccomp_la-arch-mips.lo
CC libseccomp_la-arch-mips-syscalls.lo
CC libseccomp_la-arch-mips64.lo
CC libseccomp_la-arch-mips64-syscalls.lo
CC libseccomp_la-arch-mips64n32.lo
CC libseccomp_la-arch-mips64n32-syscalls.lo
CC libseccomp_la-arch-parisc.lo
CC libseccomp_la-arch-parisc64.lo
CC libseccomp_la-arch-parisc-syscalls.lo
CC libseccomp_la-arch-ppc.lo
CC libseccomp_la-arch-ppc-syscalls.lo
CC libseccomp_la-arch-ppc64.lo
CC libseccomp_la-arch-ppc64-syscalls.lo
CC libseccomp_la-arch-riscv64.lo
CC libseccomp_la-arch-riscv64-syscalls.lo
CC libseccomp_la-arch-s390.lo
CC libseccomp_la-arch-s390-syscalls.lo
CC libseccomp_la-arch-s390x.lo
CC libseccomp_la-arch-s390x-syscalls.lo
CCLD libseccomp.la
Making all in tools
CC scmp_sys_resolver.o
../../libseccomp/tools/scmp_sys_resolver.c:29:10: fatal error: seccomp.h: No such file or directory
29 | #include <seccomp.h>
| ^~~~~~~~~~~
compilation terminated.
make[2]: *** [Makefile:524: scmp_sys_resolver.o] Error 1
make[1]: *** [Makefile:514: all-recursive] Error 1
make: *** [Makefile:423: all] Error 2

@pcmoore
Copy link
Member

pcmoore commented Feb 26, 2020

You did not show the git clone or the autogen.sh, please follow the instructions exactly in my earlier comment. I don't understand why you keep withholding the requested information, but it is making it very difficult for us to properly review this PR.

Also, it looks like this is a RISC-V build target, yes? Are you building natively or cross-compiling?

@pcmoore
Copy link
Member

pcmoore commented Feb 26, 2020

Note to self: it is also odd that the build works for everything in "src/", but fails in "tools/". There are plenty of source files in "src/" which include "seccomp.h" so I would have expected the build to fail there as well, but it doesn't.

Something is very odd here.

@andreas-schwab
Copy link
Author

src/Makefile.am already contains -I${top_builddir}/include.

@pcmoore
Copy link
Member

pcmoore commented Feb 26, 2020

You did not show the git clone or the autogen.sh, please follow the instructions exactly in my earlier comment. I don't understand why you keep withholding the requested information, but it is making it very difficult for us to properly review this PR.

Also, it looks like this is a RISC-V build target, yes? Are you building natively or cross-compiling?

@coveralls
Copy link

coveralls commented Feb 26, 2020

Coverage Status

Coverage remained the same at 90.977% when pulling f7d8fc3 on andreas-schwab:master into 38f04da on seccomp:master.

@pcmoore
Copy link
Member

pcmoore commented Feb 28, 2020

@andreas-schwab I'd really like to understand this problem more, could you answer the questions please?

  • Is this being built for a RISC-V target?
  • Are you cross-compiling? If so, what is the host architecture?
  • Please supply us the build output starting with the git clone using the commands from this comment

I'm guessing this is all due to cross-compiling, but I can't be certain due to the lack of information. I also have some concerns about the resulting binary, it would be nice to have a conversation about cross-compiling (does the resulting library work properly?) if you are able to answer the questions above.

@pcmoore pcmoore changed the title build: append -I${top_builddir}/include to AM_CPPFLAGS BUG: append -I${top_builddir}/include to AM_CPPFLAGS Feb 28, 2020
@giuseppe
Copy link
Contributor

@pcmoore I am also hitting a similar issue when building from a VPATH. The issue is solved by this patch.

To reproduce the issue I've seen, you can use these steps:

$ git clone https://github.com/seccomp/libseccomp
$ cd libseccomp
$ ./autogen.sh
$ mkdir build
$ cd build
$ ../configure
$ make
....
../../tools/scmp_arch_detect.c: In function ‘main’:
../../tools/scmp_arch_detect.c:123:8: error: ‘SCMP_ARCH_RISCV64’ undeclared (first use in this function); did you mean ‘SCMP_ARCH_PARISC64’?
  123 |   case SCMP_ARCH_RISCV64:
      |        ^~~~~~~~~~~~~~~~~
      |        SCMP_ARCH_PARISC64


Move -I${top_builddir}/include to toplevel so that it is available in all
subdirs.  This is needed to find <seccomp.h> in the build directory, since
it is now a generated file.

Signed-off-by: Andreas Schwab <schwab@suse.de>
@andreas-schwab andreas-schwab changed the title BUG: append -I${top_builddir}/include to AM_CPPFLAGS BUG: fix building outside source directory Mar 2, 2020
@pcmoore
Copy link
Member

pcmoore commented Mar 5, 2020

Thanks, the reproducer helps a lot.

This patch looks good to me, are you okay with this @drakenclimber?

@pcmoore
Copy link
Member

pcmoore commented Mar 10, 2020

Since this is a trivial fix and it has been five days I'm going to go ahead and merge this with 26b483b, thanks everyone!

@pcmoore pcmoore closed this Mar 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants