Skip to content

Commit

Permalink
Fix build on FreeBSD (re: d41c52d)
Browse files Browse the repository at this point in the history
Now the build on FreeBSD was failing because the standards macros
needed to expose SA_RESTART hid a bunch of BSD stuff. OpenBSD has
_BSD_SOURCE and NetBSD has _NETBSD_SOURCE to deal with this, but
FreeBSD and derivatives have no such thing.

src/lib/libast/features/standards:
- Define the internal undocumented macro __BSD_VISIBLE to expose
  the BSD stuff on FreeBSD.

src/lib/libcmd/Mamfile:
- Fix a parallelism bug discovered on FreeBSD (which creates
  processes extremely fast). When building with e.g. -j9,
  compilation of the *.c files started before the generation of
  cmdext.h was finished, causing the first couple of compilations
  to get an empty or incomplete cmdext.h. Add the 'prev' needed to
  wait for it.
  • Loading branch information
McDutchie committed Aug 16, 2024
1 parent aeaf0d2 commit 10efe79
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib/libast/features/standards
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ if tst note{ BSD (Free, Net, Open, et al) }end compile{
}end {
#define _XOPEN_SOURCE 9900
#define _POSIX_C_SOURCE 21000101L
#define _BSD_SOURCE 1
#define _NETBSD_SOURCE 1
#define _BSD_SOURCE 1 /* OpenBSD needs this */
#define _NETBSD_SOURCE 1 /* NetBSD needs this */
#define __BSD_VISIBLE 1 /* FreeBSD needs this */
}
elif tst note{ Darwin (macOS, Mac OS X) }end compile{
/*
Expand Down
3 changes: 3 additions & 0 deletions src/lib/libcmd/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ make install virtual
make libcmd.a
loop OBJ cmdinit basename cat chgrp chmod chown cksum cmp comm cp cut dirname date expr fds fmt fold getconf head id join ln logname md5sum mkdir mkfifo mktemp mv paste pathchk pids rev rm rmdir stty sum sync tail tee tty uname uniq wc revlib wclib lib
make %{OBJ}.o
note * cmdext.h is included by cmd.h but generated after cmd.h is
note * declared, so we declare the dependency on it here instead.
prev cmdext.h
prev %{OBJ}.c
exec - %{CC} %{mam_cc_FLAGS} %{CCFLAGS} %{mam_cc_NOSTRICTALIASING} -I. -I%{INCLUDE_AST} -DERROR_CATALOG=\""libcmd"\" -DHOSTTYPE=\""%{mam_cc_HOSTTYPE}"\" -D_BLD_cmd -c %{<}
done
Expand Down

0 comments on commit 10efe79

Please sign in to comment.