@@ -12,6 +12,11 @@ pub fn build(b: *Build) !void {
1212 "link_mode" ,
1313 "Compile static or dynamic libraries. Defaults to dynamic" ,
1414 ) orelse .dynamic ;
15+ const pic = b .option (
16+ bool ,
17+ "pic" ,
18+ "Produce Position Independent Code. Defaults to true when link_mode is dynamic" ,
19+ ) orelse (linkmode == .dynamic );
1520
1621 // Dependencies
1722 const upstream = b .dependency ("upstream" , .{});
@@ -29,6 +34,7 @@ pub fn build(b: *Build) !void {
2934 .target = target ,
3035 .optimize = optimize ,
3136 .link_libc = true ,
37+ .pic = pic ,
3238 });
3339 const libcares = b .addLibrary (.{ .name = "cares" , .root_module = caresmod });
3440 const cares_config = switch (target .result .os .tag ) {
@@ -62,6 +68,7 @@ pub fn build(b: *Build) !void {
6268 .target = target ,
6369 .optimize = optimize ,
6470 .link_libcpp = true ,
71+ .pic = pic ,
6572 });
6673 const libabseil = b .addLibrary (.{ .name = "abseil" , .root_module = abseilmod });
6774 abseilmod .addCSourceFiles (.{
@@ -80,6 +87,7 @@ pub fn build(b: *Build) !void {
8087 .target = target ,
8188 .optimize = optimize ,
8289 .link_libc = true ,
90+ .pic = pic ,
8391 });
8492 const libutf8 = b .addLibrary (.{ .name = "utf8-range" , .root_module = utf8mod });
8593 utf8mod .addCSourceFiles (.{
@@ -98,6 +106,7 @@ pub fn build(b: *Build) !void {
98106 .target = target ,
99107 .optimize = optimize ,
100108 .link_libc = true ,
109+ .pic = pic ,
101110 });
102111 const libupb = b .addLibrary (.{ .name = "upb" , .root_module = upbmod });
103112 upbmod .addCSourceFiles (.{
@@ -122,6 +131,7 @@ pub fn build(b: *Build) !void {
122131 .target = target ,
123132 .optimize = optimize ,
124133 .link_libcpp = true ,
134+ .pic = pic ,
125135 });
126136 const libssl = b .addLibrary (.{ .name = "ssl" , .root_module = sslmod });
127137 sslmod .addCSourceFiles (.{
@@ -142,6 +152,7 @@ pub fn build(b: *Build) !void {
142152 .target = target ,
143153 .optimize = optimize ,
144154 .link_libc = true ,
155+ .pic = pic ,
145156 });
146157 const libz = b .addLibrary (.{ .name = "z" , .root_module = zmod });
147158 zmod .addCSourceFiles (.{
@@ -160,6 +171,7 @@ pub fn build(b: *Build) !void {
160171 .target = target ,
161172 .optimize = optimize ,
162173 .link_libc = true ,
174+ .pic = pic ,
163175 });
164176 const libaddrsort = b .addLibrary (.{ .name = "addresssorting" , .root_module = addrsort });
165177 addrsort .addCSourceFiles (.{
@@ -176,6 +188,7 @@ pub fn build(b: *Build) !void {
176188 .target = target ,
177189 .optimize = optimize ,
178190 .link_libcpp = true ,
191+ .pic = pic ,
179192 });
180193 const libre2 = b .addLibrary (.{ .name = "re2" , .root_module = re2mod });
181194 re2mod .addCSourceFiles (.{
@@ -192,6 +205,7 @@ pub fn build(b: *Build) !void {
192205 .target = target ,
193206 .optimize = optimize ,
194207 .link_libcpp = true ,
208+ .pic = pic ,
195209 });
196210 const libgrpc = b .addLibrary (.{
197211 .name = "grpc" ,
0 commit comments