File tree 1 file changed +18
-6
lines changed
1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -419,12 +419,24 @@ class CodegenVisitor : public Visitor {
419
419
std::string arg = (" /DEFAULTLIB:\" " + name + " \" " ).str ();
420
420
gIR ->addLinkerOption (llvm::StringRef (arg));
421
421
} else {
422
- size_t const n = name.size () + 3 ;
423
- char *arg = static_cast <char *>(mem.xmalloc (n));
424
- arg[0 ] = ' -' ;
425
- arg[1 ] = ' l' ;
426
- memcpy (arg + 2 , name.data (), name.size ());
427
- arg[n - 1 ] = 0 ;
422
+ bool isStaticLib = name.endswith (" .a" );
423
+
424
+ size_t const nameLen = name.size ();
425
+ size_t const n = nameLen + 3 ;
426
+ char *arg = nullptr ;
427
+
428
+ if (isStaticLib == false ) {
429
+ arg = static_cast <char *>(mem.xmalloc (n));
430
+ arg[0 ] = ' -' ;
431
+ arg[1 ] = ' l' ;
432
+ memcpy (arg + 2 , name.data (), name.size ());
433
+ arg[n - 1 ] = 0 ;
434
+ } else {
435
+ arg = static_cast <char *>((mem.xmalloc (nameLen + 1 )));
436
+ memcpy (arg, name.data (), nameLen);
437
+ arg[nameLen] = 0 ;
438
+ }
439
+
428
440
global.params .linkswitches .push (arg);
429
441
430
442
if (triple.isOSBinFormatMachO ()) {
You can’t perform that action at this time.
0 commit comments