xref: /openbsd-src/share/man/man1/clang-local.1 (revision 896063e4d924bef6229f6695f274b5282f1e3d23)
1.\" $OpenBSD: clang-local.1,v 1.24 2024/06/02 15:40:43 deraadt Exp $
2.\"
3.\" Copyright (c) 2016 Pascal Stumpf <pascal@stumpf.co>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.\"
18.Dd $Mdocdate: June 2 2024 $
19.Dt CLANG-LOCAL 1
20.Os
21.Sh NAME
22.Nm clang-local
23.Nd OpenBSD-specific behavior of LLVM/clang
24.Sh DESCRIPTION
25On
26.Ox ,
27the LLVM/clang compiler exhibits the following characteristics:
28.Bl -dash
29.It
30.Nm clang
31does not search under
32.Pa /usr/local
33for include files or libraries:
34as a system compiler, it only searches the system paths by default.
35.It
36.Nm clang
37comes with stack protection enabled by default, equivalent to the
38.Fl fstack-protector-strong
39option on other systems.
40The system will report any violation of the stack protector cookie along
41with the function name via
42.Xr syslog 3
43at
44.Dv LOG_CRIT
45priority.
46.It
47.Nm clang
48will generate PIE code by default, allowing the system to load the resulting
49binary at a random location.
50This behavior can be turned off by passing
51.Fl fno-pie
52to the compiler and
53.Fl nopie
54to the linker.
55It is also turned off when the
56.Fl pg
57flag is used.
58.It
59The
60.Fl fstrict-aliasing
61option is turned off by default unless
62.Fl Ofast
63has been selected.
64.It
65.Nm clang
66does not store its version string in objects.
67There is no option to control this.
68.It
69The
70.Fl p
71flag is an alias of
72.Fl pg .
73.It
74.Nm clang
75does not warn for passing pointer arguments or assignment with
76different signedness outside of
77.Fl pedantic .
78This can be
79re-enabled with the
80.Fl Wpointer-sign
81flag.
82.It
83The warning option
84.Fl Waddress-of-packed-member
85is disabled by default.
86.It
87Color diagnostic messages are disabled by default and can be re-enabled with
88.Fl fdiagnostics-color .
89.It
90The
91.Fl fwrapv
92option to treat signed integer overflows as defined is enabled by default to
93prevent dangerous optimizations which could remove security critical overflow
94checks.
95.It
96The base system includes the ubsan_minimal sanitizer runtime
97but not the fully-featured ubsan runtime.
98See the documentation for the
99.Fl fsanitize-minimal-runtime
100flag.
101.It
102The
103.Xr malloc 3 ,
104.Xr calloc 3 ,
105.Xr realloc 3 ,
106.Xr strdup 3 ,
107.Xr strndup 3 ,
108.Xr valloc 3
109and
110.Xr free 3
111builtins are disabled to prevent undesirable optimizations of calls to
112these functions.
113.It
114.Nm clang
115includes a security pass that exchanges some ROP-friendly instructions
116with safer alternatives on i386 and amd64.
117This can be disabled with the
118.Fl fno-fixup-gadgets
119option.
120.It
121.Nm clang
122includes a security pass that can clear the return address on the
123stack upon return from calling a function, on i386 and amd64.
124This can be enabled with the
125.Fl fret-clean
126option.
127.It
128.Nm clang
129includes the retguard security feature on amd64, arm64, mips64, powerpc
130and powerpc64.
131This feature can be disabled with the
132.Fl fno-ret-protector
133or
134.Fl fno-stack-protector
135options.
136.It
137.Nm clang
138has
139.Fl mretpoline
140enabled by default on amd64 to protect against branch target injection attacks.
141It can be disabled with
142.Fl mno-retpoline .
143.It
144A new warning for
145.Cm %n
146format specifier usage in
147.Xr printf 3
148family functions has been added.
149.El
150.Sh SEE ALSO
151.Xr clang 1
152