Page MenuHomeFreeBSD

legacy: Use -isystem for system header overrides.
AbandonedPublic

Authored by bdrewery on Nov 20 2020, 8:54 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 20 2023, 6:00 AM
Unknown Object (File)
May 23 2023, 12:23 PM
Unknown Object (File)
Mar 22 2023, 7:46 AM
Unknown Object (File)
Mar 4 2023, 9:10 PM
Unknown Object (File)
Dec 22 2022, 2:58 PM
Subscribers

Details

Summary

This isn't normally needed outside of $WORLDTMP/legacy as we use
--sysroot=$WORLDTMP in later stages.

Sponsored by: Dell EMC

I did not modify the OSX/Linux cases as I am unable to test those.

Test Plan

buildworld (amd64) is fine. A tinderbox is running.

At work I had to install libdtrace, libproc, and librtld_rb into the legacy
dirs to get a newer dtrace bootstrapped for the build. Without this it was
refusing to find the new libproc.h header and was using the
/usr/include/libproc.h one (confirmed with filemon).

I don't know why this hasn't shown up before.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 34934
Build 31948: arc lint + arc unit

Event Timeline

bdrewery created this revision.

I am perplexed why it finds libelf.h but not libproc.h.

It could *possibly* be ccache but I think -isystem is right anyhow. It is probably that dtrace.o built fine before libproc.h was present and cached. Then libproc.h showed up and changed the result even though the command and sources did not change. The error from the wrong header does not show up until later when dtrace.o is linked.

This branch is around 12.0ish.

# Meta data file /b/mnt/obj/b/mnt/src/amd64.amd64/tmp/obj-tools/cddl/usr.sbin/dtrace/dtrace.o.meta                                                                                                                                                                                                                        
CMD /usr/local/bin/ccache cc  -O2 -pipe -Werror=date-time -Wno-missing-field-initializers  -I/b/mnt/src/sys/cddl/compat/opensolaris  -I/b/mnt/src/cddl/compat/opensolaris/include  -I/b/mnt/src/cddl/usr.sbin/dtrace/../../../cddl/contrib/opensolaris/head  -I/b/mnt/src/cddl/usr.sbin/dtrace/../../../cddl/
contrib/opensolaris/lib/libdtrace/common  -I/b/mnt/src/cddl/usr.sbin/dtrace/../../../cddl/contrib/opensolaris/lib/libproc/common  -I/b/mnt/src/cddl/usr.sbin/dtrace/../../../sys/cddl/contrib/opensolaris/uts/common  -I/b/mnt/src/cddl/usr.sbin/dtrace/../../../sys/cddl/contrib/opensolaris/compat -                    
DNEED_SOLARIS_BOOLEAN -DHOSTPROG -std=gnu99  -Qunused-arguments   -I/b/mnt/obj/b/mnt/src/amd64.amd64/tmp/legacy/usr/include -c /b/mnt/src/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c -o dtrace.o
CMD
CWD /b/mnt/obj/b/mnt/src/amd64.amd64/tmp/obj-tools/cddl/usr.sbin/dtrace
TARGET dtrace.o
-- filemon acquired metadata --
# filemon version 5
# Target pid 99651
# Start 1605312897.378995
V 5
E 99654 /bin/sh
R 99654 /etc/libmap.conf
R 99654 /var/run/ld-elf.so.hints
R 99654 /lib/libedit.so.7
R 99654 /lib/libc.so.7
R 99654 /lib/libncursesw.so.8
F 99654 99655
E 99655 /usr/local/bin/ccache
R 99655 /var/tmp/ccache_memcached/ccache.conf
R 99655 /usr/bin/cc
R 99655 /b/mnt/src/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c
R 99655 /var/tmp/ccache_memcached/2/f/72001518e9ebf4f89f6d25e07646a9-43893615.manifest.sea-build11-14.99655.23vfha
W 99655 /var/tmp/ccache_memcached/2/f/72001518e9ebf4f89f6d25e07646a9-43893615.manifest.sea-build11-14.99655.23vfha
M 99655 '/var/tmp/ccache_memcached/2/f/72001518e9ebf4f89f6d25e07646a9-43893615.manifest.sea-build11-14.99655.23vfha' '/var/tmp/ccache_memcached/2/f/72001518e9ebf4f89f6d25e07646a9-43893615.manifest'
R 99655 /var/tmp/ccache_memcached/2/f/72001518e9ebf4f89f6d25e07646a9-43893615.manifest
R 99655 /usr/include/x86/endian.h
R 99655 /usr/include/sys/linker.h
R 99655 /usr/include/machine/ucontext.h
R 99655 /b/mnt/src/sys/cddl/compat/opensolaris/sys/types.h
R 99655 /usr/include/libgen.h
R 99655 /b/mnt/src/cddl/usr.sbin/dtrace/../../../sys/cddl/contrib/opensolaris/uts/common/sys/ctf_api.h
R 99655 /b/mnt/src/cddl/usr.sbin/dtrace/../../../sys/cddl/contrib/opensolaris/uts/common/sys/processor.h
R 99655 /usr/include/sys/_types.h
R 99655 /usr/include/sys/_timespec.h
R 99655 /usr/include/x86/stdarg.h
R 99655 /b/mnt/src/cddl/compat/opensolaris/include/strings.h
R 99655 /usr/include/sys/elf32.h
R 99655 /usr/include/sys/disk_zone.h
R 99655 /usr/include/machine/signal.h
R 99655 /usr/include/sys/_pthreadtypes.h
R 99655 /b/mnt/src/cddl/compat/opensolaris/include/fcntl.h
R 99655 /b/mnt/src/cddl/compat/opensolaris/include/stdlib.h
R 99655 /usr/include/signal.h
R 99655 /usr/include/sys/elf.h
R 99655 /usr/include/sys/stdint.h
R 99655 /usr/include/machine/_align.h
R 99655 /usr/include/sys/wait.h
R 99655 /b/mnt/src/cddl/usr.sbin/dtrace/../../../cddl/contrib/opensolaris/lib/libdtrace/common/dtrace.h
R 99655 /b/mnt/obj/b/mnt/src/amd64.amd64/tmp/legacy/usr/include/libelf.h
R 99655 /usr/include/sys/timespec.h
R 99655 /usr/include/xlocale/_strings.h
R 99655 /usr/include/machine/elf.h
R 99655 /usr/include/stdarg.h
R 99655 /usr/include/rtld_db.h
R 99655 /b/mnt/src/sys/cddl/compat/opensolaris/sys/feature_tests.h
R 99655 /usr/include/errno.h
R 99655 /usr/include/libproc.h
...
There is a catch with the direct mode: header files that were used by the compiler are recorded, but header files that were not used, but would have been used if they existed, are not. So, when ccache checks if a result can be taken from the cache, it currently can't check if the existence of a new header file
should invalidate the result. In practice, the direct mode is safe to use in the absolute majority of cases.

Yeah it seems to be ccache causing my problems and this change just forced a rebuild. META_MODE+filemon has the same flaw :-(.
So my reasoning is wrong.

I guess the problem is that -isystem now moves ${WORLDTMP}/legacy/usr/include after all other -I includes:

$ cc -c -v -I/tmp/dir1 -I /tmp/dir2 -I/tmp/dir3 -I/tmp/dir4 -xc /dev/null -o /dev/null
FreeBSD clang version 8.0.1 (tags/RELEASE_801/final 366581) (based on LLVM 8.0.1)
Target: x86_64-unknown-freebsd12.1
Thread model: posix
InstalledDir: /usr/bin
 "/usr/bin/cc" -cc1 -triple x86_64-unknown-freebsd12.1 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name null -mrelocation-model static -mthread-model posix -mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -v -coverage-notes-file /dev/null.gcno -resource-dir /usr/lib/clang/8.0.1 -I /tmp/dir1 -I /tmp/dir2 -I /tmp/dir3 -I /tmp/dir4 -fdebug-compilation-dir /home/alr48 -ferror-limit 19 -fmessage-length 214 -fobjc-runtime=gnustep -fdiagnostics-show-option -fcolor-diagnostics -o /dev/null -x c /dev/null -faddrsig
clang -cc1 version 8.0.1 based upon LLVM 8.0.1 default target x86_64-unknown-freebsd12.1
#include "..." search starts here:
#include <...> search starts here:
 /tmp/dir1
 /tmp/dir2
 /tmp/dir3
 /tmp/dir4
 /usr/lib/clang/8.0.1/include
 /usr/include
End of search list.
$ cc -c -v -isystem /tmp/dir1 -I /tmp/dir2 -I/tmp/dir3 -I/tmp/dir4 -xc /dev/null -o /dev/null
FreeBSD clang version 8.0.1 (tags/RELEASE_801/final 366581) (based on LLVM 8.0.1)
Target: x86_64-unknown-freebsd12.1
Thread model: posix
InstalledDir: /usr/bin
 "/usr/bin/cc" -cc1 -triple x86_64-unknown-freebsd12.1 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name null -mrelocation-model static -mthread-model posix -mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -v -coverage-notes-file /dev/null.gcno -resource-dir /usr/lib/clang/8.0.1 -isystem /tmp/dir1 -I /tmp/dir2 -I /tmp/dir3 -I /tmp/dir4 -fdebug-compilation-dir /home/alr48 -ferror-limit 19 -fmessage-length 214 -fobjc-runtime=gnustep -fdiagnostics-show-option -fcolor-diagnostics -o /dev/null -x c /dev/null -faddrsig
clang -cc1 version 8.0.1 based upon LLVM 8.0.1 default target x86_64-unknown-freebsd12.1
#include "..." search starts here:
#include <...> search starts here:
 /tmp/dir2
 /tmp/dir3
 /tmp/dir4
 /tmp/dir1
 /usr/lib/clang/8.0.1/include
 /usr/include
End of search list.

In the second case /tmp/dir1 is moved just before the default include dirs. This might be interacting badly with #incude_next<>

tools/build/mk/Makefile.boot
3

FWIW we cuddle the arg up to -isystem so that Makefiles that have a need can use :N-isystem*

The whole premise here is wrong. CCACHE_NODIRECT=1 avoids my problem. I'm not going to fix what's not broken. Sorry for the noise.