Page MenuHomeFreeBSD

Emit an error when we seen absolute paths to .o files
ClosedPublic

Authored by arichardson on Feb 3 2021, 9:58 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Apr 8, 4:56 AM
Unknown Object (File)
Sat, Mar 30, 11:37 PM
Unknown Object (File)
Feb 19 2024, 7:26 AM
Unknown Object (File)
Feb 19 2024, 6:28 AM
Unknown Object (File)
Jan 28 2024, 2:32 PM
Unknown Object (File)
Jan 28 2024, 2:32 PM
Unknown Object (File)
Jan 28 2024, 2:32 PM
Unknown Object (File)
Jan 28 2024, 2:32 PM
Subscribers

Details

Summary

This is usually an error caused by using an absolute path in SRCS. This
happened to me in 83c20b8a2da0 due to changing LDADD to SRCS.
I did not notice that this had created a .o file inside the source tree
since .gitignore contains "*.o" and therefore git did not report any
changes.

Adding this warning message to bsd.lib.mk/bsd.prog.mk should prevent
issues like this in the future.

There is one case of an absolute OBJS path in the current source tree
which I have tagged as such using _ABSOLUTE_PATH_OBJS.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 36691
Build 33580: arc lint + arc unit

Event Timeline

Example warning message:

+ make -C tests/sys/kern all -j36
make[3]: "/local/scratch/alr48/cheri/freebsd/share/mk/bsd.prog.mk" line 147: warning: "Found absolute path to .o file, this will almost certainly break the build with a read-only source directory: /local/scratch/alr48/cheri/freebsd/sys/libkern/arm64/crc32c_armv8.o"

IMO we don't need the extra commentary - e.g. maybe just "\$OBJS absolute path not allowed: ${OBJS:M/*}"

This revision is now accepted and ready to land.Feb 3 2021, 2:39 PM
  • shorten message
  • make it an error below ${SRCTOP}
This revision now requires review to proceed.Feb 3 2021, 2:50 PM

I think this is fine, we can adjust later if necessary (in case of unexpected consequences)

This revision is now accepted and ready to land.Feb 3 2021, 3:50 PM

Turns out this is triggered by loader:

===> stand/i386/loader_4th (includes)
make[5]: "/home/alr48/devel/freebsd/src/share/mk/bsd.prog.mk" line 151: warning: "$OBJS absolute path not allowed: /home/alr48/obj/freebsd/home/alr48/devel/freebsd/src/amd64.amd64/stand/i386/btx/lib/crt0.o"
===> stand/i386/loader_lua (includes)
make[5]: "/home/alr48/devel/freebsd/src/share/mk/bsd.prog.mk" line 151: warning: "$OBJS absolute path not allowed: /home/alr48/obj/freebsd/home/alr48/devel/freebsd/src/amd64.amd64/stand/i386/btx/lib/crt0.o"
===> stand/i386/loader_simp (includes)
make[5]: "/home/alr48/devel/freebsd/src/share/mk/bsd.prog.mk" line 151: warning: "$OBJS absolute path not allowed: /home/alr48/obj/freebsd/home/alr48/devel/freebsd/src/amd64.amd64/stand/i386/btx/lib/crt0.o"

This is fine since it's inside the OBJDIR, so we probably need a way to silence it? Ignore it if it starts with OBJTOP/.OBJDIR?

# XXX crt0.o needs to be first for pxeboot(8) to work
OBJS=	${BTXCRT}
This revision now requires review to proceed.Feb 3 2021, 5:05 PM
share/mk/bsd.lib.mk
262

What about folk who insist on dribbling .o's in src tree?
I may have little sympathy for them, but ...

share/mk/bsd.prog.mk
145

There are several .includes shared by bsd.lib.mk and bsd.prog.mk - why not put this in one place rather. than duplictae?

share/mk/bsd.prog.mk
145

That would indeed be much better. However, I'm not sure which file would be suitable for this. Could you suggest one?

share/mk/bsd.lib.mk
262

I could add a hidden variable such as _ALLOW_OBJS_IN_SRC to avoid this .error/.warning?

  • Move to shared file
  • add opt-out mechanism
  • Use it to fix loader build

With the latest version I get the following error :

bmake[5]: "/Users/alex/cheri/freebsd/share/mk/bsd.dep.mk" line 203: "$OBJS absolute path not allowed: /Users/alex/cheri/build/freebsd-amd64-build/Users/alex/cheri/freebsd/amd64.amd64/stand/i386/btx/lib/crt0.o.  If this is intended, add them to _ABSOLUTE_PATH_OBJS to silence this error or define _ALLOW_ABSOLUTE_OBJ_PATH to disable this diagnostic."
bmake[5]: stopped in /Users/alex/cheri/freebsd/stand/i386/loader_4th

To avoid this I changed loader/Makefile.

arichardson retitled this revision from Print a warning when we seen absolute paths to .o files to Emit an error when we seen absolute paths to .o files.Apr 1 2021, 10:00 AM
arichardson edited the summary of this revision. (Show Details)

Turns out this is triggered by loader:

===> stand/i386/loader_4th (includes)
make[5]: "/home/alr48/devel/freebsd/src/share/mk/bsd.prog.mk" line 151: warning: "$OBJS absolute path not allowed: /home/alr48/obj/freebsd/home/alr48/devel/freebsd/src/amd64.amd64/stand/i386/btx/lib/crt0.o"
===> stand/i386/loader_lua (includes)
make[5]: "/home/alr48/devel/freebsd/src/share/mk/bsd.prog.mk" line 151: warning: "$OBJS absolute path not allowed: /home/alr48/obj/freebsd/home/alr48/devel/freebsd/src/amd64.amd64/stand/i386/btx/lib/crt0.o"
===> stand/i386/loader_simp (includes)
make[5]: "/home/alr48/devel/freebsd/src/share/mk/bsd.prog.mk" line 151: warning: "$OBJS absolute path not allowed: /home/alr48/obj/freebsd/home/alr48/devel/freebsd/src/amd64.amd64/stand/i386/btx/lib/crt0.o"

This is fine since it's inside the OBJDIR, so we probably need a way to silence it? Ignore it if it starts with OBJTOP/.OBJDIR?

# XXX crt0.o needs to be first for pxeboot(8) to work
OBJS=	${BTXCRT}

I'm surprised this isn't more pervasive... I'd prefer if we suppressed the warning if it starts with OBJTOP.

arichardson edited the summary of this revision. (Show Details)

Rebased. The only time this was triggered in-tree has been fixed by e713d3a013882893fceb84dd14569052271497a9

Given the additional testing reported, I think this is good...

This revision is now accepted and ready to land.Jun 14 2021, 11:42 PM