HomeFreeBSD

MFC outstanding crunchgen work: r350152, r364166, r364174, r364234,

Description

MFC outstanding crunchgen work: r350152, r364166, r364174, r364234,
r364646-r364647, r365605, r365705

r350152:
Remove obsolete RELEASE_CRUNCH

Remove documentation of RELEASE_CRUNCH here. It's obsolete and no longer a
good example.

r364166:
Fix crunchgen usage of mkstemp()

On Glibc systems mkstemp can only be used once with the same template
string since it will be modified in-place and no longer contain any 'X'
chars. It is fine to reuse the same file here but we need to be explicit and
use open() instead of mkstemp() on the second use.

While touching this file also avoid a hardcoded /bin/pwd since that may not
work when building on non-FreeBSD systems.

r364174:
Use env pwd instead of pwd in crunchgen.c

In r364166 I changed /bin/pwd to pwd, but pwd can be shell builtin that
may not correctly return a real path. To ensure that all symlinks are
resolved use env pwd -P instead (the -P flag is part of POSIX so
should be supported everywhere).

r364234:
crunchgen: use pwd -P without env

The -P flag is required by POSIX so we don't have to care whether pwd is
a shell builtin or not. This also allows removing pwd from the list of
bootstrap tools since all shells we care about for building have a
builtin pwd command. This effectively reverts r364190.

r364646:
Re-indent crunched_main.c in preparation for D25998

r364647:
Correctly determine the real executable in crunched binaries

This should fix cases like su setting argv[0] to _su for /bin/sh.
Previously cheribsdbox (a crunched tool we use in CheriBSD to reduce the
size of our minimal disk images to allow loading them onto FPGAs without
waiting forever for the transfer) would complain about _su not being
compiled in, but now that we also look at AT_EXECPATH it correctly
invokes the sh tool.

Note: we use use AT_EXECPATH instead of the KERN_PROC_PATHNAME sysctl to get
the crunchgen binary name since it seems like KERN_PROC_PATHNAME just
returns the last cached path for a given hardlink.
When using su, instead of invoking /bin/csh this would invoke the last
used hardlink to cheribsdbox. This caused weird test failures when running
tests due to id being executed instead of echo:

$ id # id is a hardlink to /bin/cheribsdbox
$ su postgres -c 'echo 1' # su is also a hardlink
uid=1001(postgres) gid=1001(postgres) groups=1001(postgres)

r365605:
crunchgen(8): fix crunched application build with WARNS=6

This was revealed by the rescue build with a patch I'm working on to default
WARNS=6 everywhere. The issues resolved were:

  • Missing prototype for _crunched_${ident}_stub in the *_stub.c generated bits
  • Missing prototype for crunched_main
  • Incomplete prototype for _crunched_${ident}_stub in the generated parts of crunched_main
  • Literal strings in the stub table must drop const qualifier, unless we const'ify name
  • f field in struct stub didn't have a proper prototype

Most of these issues are minor formalities and easily addressed.

I note that if my patch to eventually raise WARNS for the rescue build
lands, we'll need to bump the __FreeBSD_version requirement for
bootstrapping crunchgen and wipe out the rescue .OBJDIR if it's stale, which
we should be able to detect pretty easily from a couple of the issues that
have been fixed here.

r365705:
__FreeBSD_version bump for r365605 (crunchgen producing WARNS-clean)

The change in D26397 will need a __FreeBSD_version to base off of for
bootstrapping crunchgen, to avoid avoidable build failures just because the
host has an outdated crunchgen.

Details

Provenance
kevansAuthored on
Parents
rS365815: Add check_pgrp_jobc() calls into process exit path.
Branches
Unknown
Tags
Unknown