Skip to content

Commit fb9a7c5

Browse files
final fix for problem with pic model
1 parent fc8f3c6 commit fb9a7c5

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-3
lines changed

tsc/lib/TypeScript/LowerToLLVM.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,8 @@ struct FuncOpLowering : public TsLlvmPattern<mlir_ts::FuncOp>
10391039
auto inlineLinkage = LLVM::linkage::Linkage::LinkonceODR;
10401040
auto linkage = LLVM::LinkageAttr::get(getContext(), inlineLinkage);
10411041
newFuncOp->setAttr("llvm.linkage", linkage);
1042-
newFuncOp->setAttr("dso_local", rewriter.getUnitAttr());
1042+
// TODO: dso_local somehow linked with -fno-pic
1043+
//newFuncOp->setAttr("dso_local", rewriter.getUnitAttr());
10431044
newFuncOp.setPrivate();
10441045

10451046
addComdat(newFuncOp, rewriter);

tsc/lib/TypeScript/MLIRGen.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3228,7 +3228,8 @@ class MLIRGenImpl
32283228
else if (variableDeclarationInfo.isSpecialization)
32293229
{
32303230
attrs.push_back({builder.getStringAttr("Linkage"), builder.getStringAttr("LinkonceODR")});
3231-
attrs.push_back({builder.getStringAttr("dso_local"), builder.getUnitAttr()});
3231+
// TODO: dso_local somehow linked with -fno-pic
3232+
//attrs.push_back({builder.getStringAttr("dso_local"), builder.getUnitAttr()});
32323233
}
32333234

32343235
// add modifiers

tsc/tsc/.vscode/launch.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@
423423
"-emit=dll",
424424
"-relocation-model=pic",
425425
"-verbose",
426+
"-o=${workspaceFolder}/../../../playground/lib1.so",
426427
"${workspaceFolder}/../../../playground/1.ts"
427428
],
428429
"stopAtEntry": false,

tsc/tsc/exe.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ int buildExe(int argc, char **argv, std::string objFileName, CompileOptions &com
446446
args.push_back("-ltinfo");
447447
args.push_back("-ldl");
448448
args.push_back("-lrt");
449-
args.push_back("-rdynamic"); // do we need it?
449+
//args.push_back("-rdynamic"); // do we need it?
450450
}
451451

452452
if (wasm && emscripten)

tsc/tsc/obj.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,13 @@ int setupTargetTriple(llvm::Module *llvmModule, std::unique_ptr<llvm::TargetMach
210210
return -1;
211211
}
212212

213+
// TODO: research
214+
if (RM && *RM == llvm::Reloc::PIC_)
215+
{
216+
llvmModule->setPICLevel(llvm::PICLevel::Level::BigPIC);
217+
//llvmModule->setPIELevel(llvm::PIELevel::Level::Large);
218+
}
219+
213220
auto CPUStr = llvm::codegen::getCPUStr(),
214221
FeaturesStr = llvm::codegen::getFeaturesStr();
215222

0 commit comments

Comments
 (0)