| author | |
| committer | |
| log | 399eaa3d410da35de6f5d1869932a7c0e8ca46b2 |
| tree | ef86d479fe1207e67ac6109fa1a60855d8d7d97b |
| parent | c19cd5b8920ae242e582bbb1f843c9c255318ea8 |
| signature | Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM |
This makes it so that objects and static libraries produced by Zig can be linked
into PIEs and shared libraries by default. This matches how almost all C/C++
toolchains are configured in Linux/BSD distros today.
For cases where the user knows better and wants to squeeze out some (usually
very minor) extra performance, they can just explicitly disable PIC when
producing the object or static library.1 files changed, 3 insertions(+), 4 deletions(-)
src/Module.zig+3-4| ... | ... | @@ -195,10 +195,9 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Module { |
| 195 | 195 | if (options.inherited.pic) |x| break :b x; |
| 196 | 196 | if (options.parent) |p| break :b p.pic; |
| 197 | 197 | |
| 198 | // Default to PIC on targets where we default to producing PIEs to make | |
| 199 | // the common case of linking objects and static libraries into an | |
| 200 | // executable work out of the box. | |
| 201 | break :b target_util.defaultPie(target); | |
| 198 | // Default to PIC for objects and static libraries to make the common | |
| 199 | // cases of linking those into a PIE or a shared library just work. | |
| 200 | break :b options.global.output_mode != .Exe; | |
| 202 | 201 | }; |
| 203 | 202 | |
| 204 | 203 | const red_zone = b: { |