Skip to contentSkip to conversation

Bug#906472: horst: FTBFS in buster/sid (unable to open 'stdarg.h')

DISCUSSION Uwe Kleine-König 2 participants 4 messages Sep 14, 2018 – Sep 25, 2018 3 messages not in the archive Sparse checker

lore
Share & tools
lore
#3 lore raw
In reply to a message not in the archive

Hello,

[Cc += sparse mailing list]

Quoted 25 lines · Adrian Bunk

Control: reassign -1 sparse 0.5.2-1
Control: affects -1 src:horst

Quoted 21 lines · Christoph Biedl

Santiago Vila wrote...

Quoted 4 lines

make -j1 check
make[1]: Entering directory '/<<PKGBUILDDIR>>'
sparse -g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -std=gnu99 -Wall -Wextra -g -I. -DDO_DEBUG -I/usr/include/libnl3 *.[ch] /usr/include/err.h:25:11: error: unable to open 'stdarg.h'

To reproduce this it's important to remove gcc-7 from the build chroot (apt purge libgcc-7-dev ; apt --purge autoremove).

Problem is, sparse appearently uses hardcoded paths and looks for stdarg.h in (among other places)

| /usr/lib/gcc/x86_64-linux-gnu/7//include/stdarg.h
| ^

... which fails.

Solution is to rebuild sparse, building horst was successful then. If this is true (please check!), the interesting question is why this wasn't a problem in earlier gcc version bumps.

I think this is a known limitation of sparse and there are three ways to fix this (in my order of preference):

a) let horst use cgcc -no-compile instead of sparse; or
b) let sparse depend on libgcc-7-dev (or whatever provides the necessary files); or
c) use autodetection which gcc is used and pick its files.

I'm not sure if a) fixes the problem. It fixed another problem we had with horst's usage of sparse in the past though[1].

The downside of c) is that running this autodetection on every call to sparse is probably slowing down sparse a bit which isn't nice.

Best regards
Uwe

[1] https://bugs.debian.org/873508

#4 lore raw
Quoted 3 lines · Uwe Kleine-König

Hello,

[Cc += sparse mailing list]

Sorry for the late answer.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Santiago Vila wrote...

Quoted 4 lines

make -j1 check
make[1]: Entering directory '/<<PKGBUILDDIR>>'
sparse -g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -std=gnu99 -Wall -Wextra -g -I. -DDO_DEBUG -I/usr/include/libnl3 *.[ch] /usr/include/err.h:25:11: error: unable to open 'stdarg.h'

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

To reproduce this it's important to remove gcc-7 from the build chroot (apt purge libgcc-7-dev ; apt --purge autoremove).

Problem is, sparse appearently uses hardcoded paths and looks for stdarg.h in (among other places)

Well, sparse needs to know where it can find the system header files. There is an option for this: -gcc-base-dir (and -multiarch-dir). Usually you will want to use either some that are installed by your distro or the one that match the exact GCC version you're using.

By *default*, if no -gcc-base-dir is used, sparse use the same dir as the one used by the GCC used to compile sparse itself. It's only this default that is hardcoded.

Quoted 12 lines
Quoted 3 lines
Quoted 3 lines

Solution is to rebuild sparse, building horst was successful then. If this is true (please check!), the interesting question is why this wasn't a problem in earlier gcc version bumps.

I think this is a known limitation of sparse and there are three ways to fix this (in my order of preference):

a) let horst use cgcc -no-compile instead of sparse; or
b) let sparse depend on libgcc-7-dev (or whatever provides the necessary files); or
c) use autodetection which gcc is used and pick its files.

Quoted 5 lines

I'm not sure if a) fixes the problem. It fixed another problem we had with horst's usage of sparse in the past though[1].

The downside of c) is that running this autodetection on every call to sparse is probably slowing down sparse a bit which isn't nice.

In case the default can't be used, like here, I think the best is to add in your Makefile something like:

	GCC_BASE_DIR=$(shell $(CC) -print-file-name=)
	SPARSE_FLAGS= -gcc-base-dir $(GCC_BASE_DIR)
	...
		sparse $(SPARSE_FLAGS) ...

This doesn't need to be done at each invocation of sparse (but will be done at each top-level make invocation).

Regards,
-- Luc

#5 lore raw

Hello Luc,

Quoted 11 lines · Luc Van Oostenryck
Quoted 10 lines · Uwe Kleine-König
Quoted 10 lines
Quoted 10 lines

Santiago Vila wrote...

Quoted 4 lines

make -j1 check
make[1]: Entering directory '/<<PKGBUILDDIR>>'
sparse -g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -std=gnu99 -Wall -Wextra -g -I. -DDO_DEBUG -I/usr/include/libnl3 *.[ch] /usr/include/err.h:25:11: error: unable to open 'stdarg.h'

To reproduce this it's important to remove gcc-7 from the build chroot (apt purge libgcc-7-dev ; apt --purge autoremove).

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Problem is, sparse appearently uses hardcoded paths and looks for stdarg.h in (among other places)

Well, sparse needs to know where it can find the system header files. There is an option for this: -gcc-base-dir (and -multiarch-dir). Usually you will want to use either some that are installed by your distro or the one that match the exact GCC version you're using.

I think I don't want to impose on sparse users to know the system header location.

Quoted 3 lines

By *default*, if no -gcc-base-dir is used, sparse use the same dir as the one used by the GCC used to compile sparse itself. It's only this default that is hardcoded.

I wasn't sure if this is expected to work. I had in mind, that the version of gcc is used somewhere but couldn't find proof for that.

Quoted 6 lines

In case the default can't be used, like here, I think the best is to add in your Makefile something like:

	GCC_BASE_DIR=$(shell $(CC) -print-file-name=)
	SPARSE_FLAGS= -gcc-base-dir $(GCC_BASE_DIR)
	...
		sparse $(SPARSE_FLAGS) ...

IMHO it is sensible to let sparse depend on (or at least recommend) gcc. And then the default value should be right.

Quoted 2 lines

This doesn't need to be done at each invocation of sparse (but will be done at each top-level make invocation).

I'd say you'd need := for this effect instead of =. But as I intend to make sure that with sparse the default headers are also available, this is a non-issue. (And this only happened because sparse was built with gcc-7 while horst was built with gcc-8.)

Best regards and thanks for your valuable input,
Uwe

#6 lore raw
Quoted 6 lines · Uwe Kleine-König
Quoted 3 lines

By *default*, if no -gcc-base-dir is used, sparse use the same dir as the one used by the GCC used to compile sparse itself. It's only this default that is hardcoded.

I wasn't sure if this is expected to work. I had in mind, that the version of gcc is used somewhere but couldn't find proof for that.

Several other flags have their default value corresponding to the GCC used to compile sparse: for example the architecture (x86, x86-64) or the endianness. The one you're thinking about is probably the macros for the GCC version: __GNUC__, __GNUC_MINOR__ & __GNUC_PATCHLEVEL__.

As far as I know, everything that should matter can be set explicitly either by defining the macro via -D...=... or an explicit flag like -m{32,64}, -m{little,big}-endian, -funsigned-char, ...

When using sparse for userspace code, it may be best to use the cgcc wrapper since it take care to set (some of) these values. I'm saying 'may' because personnaly, I have no experience of using sparse via cgcc (as an user, I've only used sparse for OS or bare-metal code) but I know others use it like so (for example for git).

Quoted 7 lines
Quoted 6 lines

In case the default can't be used, like here, I think the best is to add in your Makefile something like:

	GCC_BASE_DIR=$(shell $(CC) -print-file-name=)
	SPARSE_FLAGS= -gcc-base-dir $(GCC_BASE_DIR)
	...
		sparse $(SPARSE_FLAGS) ...
Quoted 7 lines

IMHO it is sensible to let sparse depend on (or at least recommend) gcc. And then the default value should be right.

Quoted 2 lines

This doesn't need to be done at each invocation of sparse (but will be done at each top-level make invocation).

I'd say you'd need := for this effect instead of =.

Yes, indeed.

Quoted 2 lines

Best regards and thanks for your valuable input,
Uwe

You're very welcome,
-- Luc