Skip to content

Commit 833d4c9

Browse files
authored
Merge pull request #23835 from alexrp/freebsd-libc
Support dynamically-linked FreeBSD libc when cross-compiling
2 parents c390671 + f3e851d commit 833d4c9

File tree

1,916 files changed

+369308
-70
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,916 files changed

+369308
-70
lines changed

CMakeLists.txt

+8-7
Original file line numberDiff line numberDiff line change
@@ -586,11 +586,12 @@ set(ZIG_STAGE2_SOURCES
586586
src/codegen/spirv/spec.zig
587587
src/crash_report.zig
588588
src/dev.zig
589-
src/glibc.zig
589+
src/libs/freebsd.zig
590+
src/libs/glibc.zig
590591
src/introspect.zig
591-
src/libcxx.zig
592-
src/libtsan.zig
593-
src/libunwind.zig
592+
src/libs/libcxx.zig
593+
src/libs/libtsan.zig
594+
src/libs/libunwind.zig
594595
src/link.zig
595596
src/link/C.zig
596597
src/link/Coff.zig
@@ -663,8 +664,8 @@ set(ZIG_STAGE2_SOURCES
663664
src/link/tapi/yaml.zig
664665
src/link/tapi/yaml/test.zig
665666
src/main.zig
666-
src/mingw.zig
667-
src/musl.zig
667+
src/libs/mingw.zig
668+
src/libs/musl.zig
668669
src/mutable_value.zig
669670
src/print_air.zig
670671
src/print_env.zig
@@ -675,7 +676,7 @@ set(ZIG_STAGE2_SOURCES
675676
src/target.zig
676677
src/tracy.zig
677678
src/translate_c.zig
678-
src/wasi_libc.zig
679+
src/libs/wasi_libc.zig
679680
)
680681

681682
if(MSVC)

lib/libc/freebsd/COPYRIGHT

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# @(#)COPYRIGHT 8.2 (Berkeley) 3/21/94
2+
3+
The compilation of software known as FreeBSD is distributed under the
4+
following terms:
5+
6+
Copyright (c) 1992-2023 The FreeBSD Project.
7+
8+
Redistribution and use in source and binary forms, with or without
9+
modification, are permitted provided that the following conditions
10+
are met:
11+
1. Redistributions of source code must retain the above copyright
12+
notice, this list of conditions and the following disclaimer.
13+
2. Redistributions in binary form must reproduce the above copyright
14+
notice, this list of conditions and the following disclaimer in the
15+
documentation and/or other materials provided with the distribution.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23+
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27+
SUCH DAMAGE.
28+
29+
The 4.4BSD and 4.4BSD-Lite software is distributed under the following
30+
terms:
31+
32+
All of the documentation and software included in the 4.4BSD and 4.4BSD-Lite
33+
Releases is copyrighted by The Regents of the University of California.
34+
35+
Copyright 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
36+
The Regents of the University of California. All rights reserved.
37+
38+
Redistribution and use in source and binary forms, with or without
39+
modification, are permitted provided that the following conditions
40+
are met:
41+
1. Redistributions of source code must retain the above copyright
42+
notice, this list of conditions and the following disclaimer.
43+
2. Redistributions in binary form must reproduce the above copyright
44+
notice, this list of conditions and the following disclaimer in the
45+
documentation and/or other materials provided with the distribution.
46+
3. All advertising materials mentioning features or use of this software
47+
must display the following acknowledgement:
48+
This product includes software developed by the University of
49+
California, Berkeley and its contributors.
50+
4. Neither the name of the University nor the names of its contributors
51+
may be used to endorse or promote products derived from this software
52+
without specific prior written permission.
53+
54+
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
55+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57+
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
58+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60+
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64+
SUCH DAMAGE.
65+
66+
The Institute of Electrical and Electronics Engineers and the American
67+
National Standards Committee X3, on Information Processing Systems have
68+
given us permission to reprint portions of their documentation.
69+
70+
In the following statement, the phrase ``this text'' refers to portions
71+
of the system documentation.
72+
73+
Portions of this text are reprinted and reproduced in electronic form in
74+
the second BSD Networking Software Release, from IEEE Std 1003.1-1988, IEEE
75+
Standard Portable Operating System Interface for Computer Environments
76+
(POSIX), copyright C 1988 by the Institute of Electrical and Electronics
77+
Engineers, Inc. In the event of any discrepancy between these versions
78+
and the original IEEE Standard, the original IEEE Standard is the referee
79+
document.
80+
81+
In the following statement, the phrase ``This material'' refers to portions
82+
of the system documentation.
83+
84+
This material is reproduced with permission from American National
85+
Standards Committee X3, on Information Processing Systems. Computer and
86+
Business Equipment Manufacturers Association (CBEMA), 311 First St., NW,
87+
Suite 500, Washington, DC 20001-2178. The developmental work of
88+
Programming Language C was completed by the X3J11 Technical Committee.
89+
90+
The views and conclusions contained in the software and documentation are
91+
those of the authors and should not be interpreted as representing official
92+
policies, either expressed or implied, of the Regents of the University
93+
of California.
94+
95+
96+
NOTE: The copyright of UC Berkeley's Berkeley Software Distribution ("BSD")
97+
source has been updated. The copyright addendum may be found at
98+
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change and is
99+
included below.
100+
101+
July 22, 1999
102+
103+
To All Licensees, Distributors of Any Version of BSD:
104+
105+
As you know, certain of the Berkeley Software Distribution ("BSD") source
106+
code files require that further distributions of products containing all or
107+
portions of the software, acknowledge within their advertising materials
108+
that such products contain software developed by UC Berkeley and its
109+
contributors.
110+
111+
Specifically, the provision reads:
112+
113+
" * 3. All advertising materials mentioning features or use of this software
114+
* must display the following acknowledgement:
115+
* This product includes software developed by the University of
116+
* California, Berkeley and its contributors."
117+
118+
Effective immediately, licensees and distributors are no longer required to
119+
include the acknowledgement within advertising materials. Accordingly, the
120+
foregoing paragraph of those BSD Unix files containing it is hereby deleted
121+
in its entirety.
122+
123+
William Hoskins
124+
Director, Office of Technology Licensing
125+
University of California, Berkeley

lib/libc/freebsd/abilists

44.8 KB
Binary file not shown.
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* Empty so we can include this unconditionally */
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* LINTLIBRARY */
2+
/*-
3+
* Copyright 1996-1998 John D. Polstra.
4+
* Copyright 2014 Andrew Turner.
5+
* Copyright 2014-2015 The FreeBSD Foundation.
6+
* All rights reserved.
7+
*
8+
* Portions of this software were developed by Andrew Turner
9+
* under sponsorship from the FreeBSD Foundation.
10+
*
11+
* Redistribution and use in source and binary forms, with or without
12+
* modification, are permitted provided that the following conditions
13+
* are met:
14+
* 1. Redistributions of source code must retain the above copyright
15+
* notice, this list of conditions and the following disclaimer.
16+
* 2. Redistributions in binary form must reproduce the above copyright
17+
* notice, this list of conditions and the following disclaimer in the
18+
* documentation and/or other materials provided with the distribution.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
*/
31+
32+
#include <sys/cdefs.h>
33+
#include "csu_common.h"
+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/* LINTLIBRARY */
2+
/*-
3+
* Copyright 1996-1998 John D. Polstra.
4+
* Copyright 2014 Andrew Turner.
5+
* Copyright 2014-2015 The FreeBSD Foundation.
6+
* All rights reserved.
7+
*
8+
* Portions of this software were developed by Andrew Turner
9+
* under sponsorship from the FreeBSD Foundation.
10+
*
11+
* Redistribution and use in source and binary forms, with or without
12+
* modification, are permitted provided that the following conditions
13+
* are met:
14+
* 1. Redistributions of source code must retain the above copyright
15+
* notice, this list of conditions and the following disclaimer.
16+
* 2. Redistributions in binary form must reproduce the above copyright
17+
* notice, this list of conditions and the following disclaimer in the
18+
* documentation and/or other materials provided with the distribution.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
*/
31+
32+
#include <machine/asm.h>
33+
#include <sys/elf_common.h>
34+
35+
/*
36+
* The program entry point
37+
* void _start(char **ap, void (*cleanup)(void)) __dead2
38+
*/
39+
ENTRY(_start)
40+
.cfi_undefined x30
41+
mov x3, x2 /* cleanup */
42+
add x1, x0, #8 /* load argv */
43+
ldr x0, [x0] /* load argc */
44+
add x2, x1, x0, lsl #3 /* env is after argv */
45+
add x2, x2, #8 /* argv is null terminated */
46+
#ifdef PIC
47+
adrp x4, :got:main
48+
ldr x4, [x4, :got_lo12:main]
49+
#else
50+
ldr x4, =main
51+
#endif
52+
#ifdef GCRT
53+
ldr x5, =eprol
54+
ldr x6, =etext
55+
/*
56+
* __libc_start1_gcrt(argc, argv, env, cleanup, main, &eprol, &etext)
57+
*/
58+
bl __libc_start1_gcrt
59+
eprol:
60+
#else
61+
/* __libc_start1(argc, argv, env, cleanup, main) */
62+
bl __libc_start1
63+
#endif
64+
END(_start)
65+
66+
.section .note.GNU-stack,"",@progbits
67+
68+
GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)

lib/libc/freebsd/lib/csu/amd64/crt.h

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*-
2+
* SPDX-License-Identifier: BSD-1-Clause
3+
*
4+
* Copyright 2018 Andrew Turner
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions
8+
* are met:
9+
* 1. Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
*
12+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
13+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
14+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
15+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
16+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
18+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
19+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22+
*/
23+
24+
#ifndef _CRT_H_
25+
#define _CRT_H_
26+
27+
/* zig patch: no HAVE_CTORS */
28+
#define INIT_CALL_SEQ(func) "call " __STRING(func)
29+
30+
#endif
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* LINTLIBRARY */
2+
/*-
3+
* SPDX-License-Identifier: BSD-2-Clause
4+
*
5+
* Copyright 1996-1998 John D. Polstra.
6+
* All rights reserved.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted provided that the following conditions
10+
* are met:
11+
* 1. Redistributions of source code must retain the above copyright
12+
* notice, this list of conditions and the following disclaimer.
13+
* 2. Redistributions in binary form must reproduce the above copyright
14+
* notice, this list of conditions and the following disclaimer in the
15+
* documentation and/or other materials provided with the distribution.
16+
*
17+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
*/
28+
29+
#include <sys/cdefs.h>
30+
#include "csu_common.h"

0 commit comments

Comments
 (0)