Skip to content

Commit 599f563

Browse files
committed
Implement new Target::supportsLinkerDirective() properly
1 parent dae17c2 commit 599f563

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

dmd/target.d

+1-2
Original file line numberDiff line numberDiff line change
@@ -811,8 +811,7 @@ version (IN_LLVM)
811811
Expression getTargetInfo(const(char)* name, const ref Loc loc);
812812
bool isCalleeDestroyingArgs(TypeFunction tf);
813813
bool libraryObjectMonitors(FuncDeclaration fd, Statement fbody) { return true; }
814-
bool supportsLinkerDirective() const { return true; }
815-
814+
bool supportsLinkerDirective() const;
816815
}
817816
else // !IN_LLVM
818817
{

gen/declarations.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "dmd/init.h"
1818
#include "dmd/nspace.h"
1919
#include "dmd/root/rmem.h"
20+
#include "dmd/target.h"
2021
#include "dmd/template.h"
2122
#include "driver/cl_options.h"
2223
#include "gen/classes.h"
@@ -440,7 +441,7 @@ class CodegenVisitor : public Visitor {
440441
}
441442
} else if (decl->ident == Id::linkerDirective) {
442443
// embed in object file (if supported)
443-
if (triple.isWindowsMSVCEnvironment() || triple.isOSBinFormatMachO()) {
444+
if (target.supportsLinkerDirective()) {
444445
assert(decl->args);
445446
llvm::SmallVector<llvm::StringRef, 2> args;
446447
args.reserve(decl->args->length);

gen/target.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -325,3 +325,8 @@ bool Target::isCalleeDestroyingArgs(TypeFunction* tf) {
325325
return global.params.targetTriple->isWindowsMSVCEnvironment() ||
326326
tf->linkage != LINK::cpp;
327327
}
328+
329+
bool Target::supportsLinkerDirective() const {
330+
return global.params.targetTriple->isWindowsMSVCEnvironment() ||
331+
global.params.targetTriple->isOSBinFormatMachO();
332+
}
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// RUN: %ldc -mtriple=x86_64-linux-gnu -output-ll -of=%t.ll %s && FileCheck %s < %t.ll
1+
// RUN: not %ldc -mtriple=x86_64-linux-gnu -o- %s
2+
// RUN: %ldc -mtriple=x86_64-linux-gnu -ignore -output-ll -of=%t.ll %s && FileCheck %s < %t.ll
23

34
// REQUIRES: target_X86
45

56
// CHECK: !llvm.dependent-libraries = !{!0}
67
// CHECK: !0 = !{!"mylib"}
78
pragma(lib, "mylib");
89

9-
// silently ignored because not (yet?) embeddable in ELF object file:
10+
// not (yet?) embeddable in ELF object file
1011
pragma(linkerDirective, "-myflag");
11-
pragma(linkerDirective, "-framework", "CoreFoundation");

0 commit comments

Comments
 (0)