authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-05-07 01:58:18-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-05-07 01:58:18-07:00
logd5d5fd928c79df6e4060c7ad84068fcee28c2391
treebfc30cb8a4906150daf017e309d9bf98b473c4f3
parentc098a8f5223855b410895b5396948e3e2b3aacba

link: don't put -l in front of .a or .so files


2 files changed, 29 insertions(+), 3 deletions(-)

src/buffer.hpp+21-2
......@@ -140,11 +140,30 @@ static inline bool buf_eql_str(Buf *buf, const char *str) {
140140 return buf_eql_mem(buf, str, strlen(str));
141141}
142142
143static inline bool buf_starts_with_mem(Buf *buf, const char *mem, int mem_len) {
144 if (buf_len(buf) < mem_len) {
145 return false;
146 }
147 return memcmp(buf_ptr(buf), mem, mem_len) == 0;
148}
149
143150static inline bool buf_starts_with_buf(Buf *buf, Buf *sub) {
144 if (buf_len(buf) < buf_len(sub)) {
151 return buf_starts_with_mem(buf, buf_ptr(sub), buf_len(sub));
152}
153
154static inline bool buf_starts_with_str(Buf *buf, const char *str) {
155 return buf_starts_with_mem(buf, str, strlen(str));
156}
157
158static inline bool buf_ends_with_mem(Buf *buf, const char *mem, int mem_len) {
159 if (buf_len(buf) < mem_len) {
145160 return false;
146161 }
147 return buf_eql_mem(sub, buf_ptr(buf), buf_len(sub));
162 return memcmp(buf_ptr(buf) + buf_len(buf) - mem_len, mem, mem_len) == 0;
163}
164
165static inline bool buf_ends_with_str(Buf *buf, const char *str) {
166 return buf_ends_with_mem(buf, str, strlen(str));
148167}
149168
150169bool buf_eql_buf(Buf *buf, Buf *other);
src/link.cpp+8-1
......@@ -238,7 +238,14 @@ static void construct_linker_job_linux(LinkJob *lj) {
238238
239239 for (int i = 0; i < g->link_libs.length; i += 1) {
240240 Buf *link_lib = g->link_libs.at(i);
241 Buf *arg = buf_sprintf("-l%s", buf_ptr(link_lib));
241 Buf *arg;
242 if (buf_starts_with_str(link_lib, "/") || buf_ends_with_str(link_lib, ".a") ||
243 buf_ends_with_str(link_lib, ".so"))
244 {
245 arg = link_lib;
246 } else {
247 arg = buf_sprintf("-l%s", buf_ptr(link_lib));
248 }
242249 lj->args.append(buf_ptr(arg));
243250 }
244251