0e1e341b48
Use of ranlib or lorder is no longer necessary with current linkers (probably anything newer than ~1990) and ar's ability to create an object index and symbol table in the archive. Currently the build system uses lorder+tsort to sort the .o files in dependency order so that a single-pass linker can use them. However, we can use the -s flag to ar to add an index to the .a file which makes lorder unnecessary. Running ar -s is equivalent to running ranlib afterwards, so we can also skip the ranlib invocation. Similarly, we don't have to pass the .o files for shared libraries in dependency order since both ld.bfd and ld.lld will correctly resolve references between the .o files. This removes many fork()+execve calls for each library so should speed up builds a bit. Additionally lorder.sh uses a regular expression that is not supported by the macOS libc or glibc and results in many warnings when cross-building (see D25989). There is one functional change: lorder.sh removed duplicated .o files from the linker command line which now no longer happens. I fixed the duplicates in the base system in r364649. I also checked the ports tree for uses of bsd.lib.mk and found one duplicate source file which I fixed in r548168. Most ports use CMake/autotools rather than bsd.lib.mk but if this breaks any ports that I missed in my search please let me know. Avoiding the shell script actually speeds up the linking step noticeably: I measured how long it takes to rebuild the .a and .so files for lib/libc using a basic benchmark: `rm $LIBC_OBJDIR/*.so* $LIBC_OBJDIR/*.a* && /usr/bin/time make -DWITHOUT_TESTS -s > /dev/null` Without this change ~4.5 seconds and afterwards ~3.1 seconds. Looking at truss -cf output we can see that the number fork() system calls goes down from 27 to 12 (and the speedup while tracing is more noticeable: 81 seconds -> 65 seconds). See also https://www.gnu.org/software/coreutils/manual/html_node/tsort-background.html for some more background: This whole procedure has been obsolete since about 1980, because Unix archives now contain a symbol table (traditionally built by ranlib, now generally built by ar itself), and the Unix linker uses the symbol table to effectively make multiple passes over an archive file. Or alternatively https://www.unix.com/man-page/osf1/1/lorder/: The lorder command is essentially obsolete. Use the following command in its place: % ar -ts file.a Reviewed By: emaste, imp, dim Differential Revision: https://reviews.freebsd.org/D26044 |
||
---|---|---|
bin | ||
cddl | ||
contrib | ||
crypto | ||
etc | ||
gnu | ||
include | ||
kerberos5 | ||
lib | ||
libexec | ||
release | ||
rescue | ||
sbin | ||
secure | ||
share | ||
stand | ||
sys | ||
targets | ||
tests | ||
tools | ||
usr.bin | ||
usr.sbin | ||
.arcconfig | ||
.arclint | ||
.cirrus.yml | ||
.clang-format | ||
.gitattributes | ||
.gitignore | ||
COPYRIGHT | ||
LOCKS | ||
MAINTAINERS | ||
Makefile | ||
Makefile.inc1 | ||
Makefile.libcompat | ||
Makefile.sys.inc | ||
ObsoleteFiles.inc | ||
README | ||
README.md | ||
RELNOTES | ||
UPDATING |
FreeBSD Source:
This is the top level of the FreeBSD source directory. This file
was last revised on:
FreeBSD
FreeBSD is an operating system used to power modern servers, desktops, and embedded platforms. A large community has continually developed it for more than thirty years. Its advanced networking, security, and storage features have made FreeBSD the platform of choice for many of the busiest web sites and most pervasive embedded networking and storage devices.
For copyright information, please see the file COPYRIGHT in this directory. Additional copyright information also exists for some sources in this tree - please see the specific source directories for more information.
The Makefile in this directory supports a number of targets for building components (or all) of the FreeBSD source tree. See build(7), config(8), https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html, and https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig.html for more information, including setting make(1) variables.
Source Roadmap:
bin System/user commands.
cddl Various commands and libraries under the Common Development
and Distribution License.
contrib Packages contributed by 3rd parties.
crypto Cryptography stuff (see crypto/README).
etc Template files for /etc.
gnu Various commands and libraries under the GNU Public License.
Please see gnu/COPYING* for more information.
include System include files.
kerberos5 Kerberos5 (Heimdal) package.
lib System libraries.
libexec System daemons.
release Release building Makefile & associated tools.
rescue Build system for statically linked /rescue utilities.
sbin System commands.
secure Cryptographic libraries and commands.
share Shared resources.
stand Boot loader sources.
sys Kernel sources.
sys/<arch>/conf Kernel configuration files. GENERIC is the configuration
used in release builds. NOTES contains documentation of
all possible entries.
tests Regression tests which can be run by Kyua. See tests/README
for additional information.
tools Utilities for regression testing and miscellaneous tasks.
usr.bin User commands.
usr.sbin System administration commands.
For information on synchronizing your source tree with one or more of the FreeBSD Project's development branches, please see:
https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/current-stable.html