mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-08 03:46:02 +03:00
Add a handful of fixes for Android
This commit is contained in:
parent
4a8b497326
commit
ee8a832c49
5 changed files with 28 additions and 8 deletions
|
@ -654,10 +654,6 @@ longdouble Port::strtold(const char *p, char **endp)
|
|||
#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __NetBSD__ || __DragonFly__ || __HAIKU__
|
||||
|
||||
#include <math.h>
|
||||
#if __linux__
|
||||
#include <bits/nan.h>
|
||||
#include <bits/mathdef.h>
|
||||
#endif
|
||||
#if __FreeBSD__ && __i386__
|
||||
#include <ieeefp.h>
|
||||
#endif
|
||||
|
|
|
@ -216,6 +216,24 @@ void CodeGenerator::emit(Module *m) {
|
|||
emitSymbolAddrGlobal(ir_->module, "__bss_start", "_d_execBssBegAddr");
|
||||
emitSymbolAddrGlobal(ir_->module, "_end", "_d_execBssEndAddr");
|
||||
}
|
||||
|
||||
// On Android, bracket TLS data with the symbols _tlsstart and _tlsend, as
|
||||
// done with dmd
|
||||
if (global.params.targetTriple.getEnvironment() == llvm::Triple::Android) {
|
||||
auto startSymbol = new llvm::GlobalVariable(
|
||||
ir_->module, llvm::Type::getInt32Ty(ir_->module.getContext()), false,
|
||||
llvm::GlobalValue::ExternalLinkage,
|
||||
llvm::ConstantInt::get(ir_->module.getContext(), APInt(32,0)),
|
||||
"_tlsstart", &*(ir_->module.global_begin()));
|
||||
startSymbol->setSection(".tdata");
|
||||
|
||||
auto endSymbol = new llvm::GlobalVariable(
|
||||
ir_->module, llvm::Type::getInt32Ty(ir_->module.getContext()), false,
|
||||
llvm::GlobalValue::ExternalLinkage,
|
||||
llvm::ConstantInt::get(ir_->module.getContext(), APInt(32,0)),
|
||||
"_tlsend");
|
||||
endSymbol->setSection(".tcommon");
|
||||
}
|
||||
}
|
||||
|
||||
finishLLModule(m);
|
||||
|
|
|
@ -164,10 +164,15 @@ static int linkObjToBinaryGcc(bool sharedLib, bool fullyStatic) {
|
|||
switch (global.params.targetTriple.getOS()) {
|
||||
case llvm::Triple::Linux:
|
||||
addSoname = true;
|
||||
args.push_back("-lrt");
|
||||
if (!opts::disableLinkerStripDead) {
|
||||
args.push_back("-Wl,--gc-sections");
|
||||
}
|
||||
if (global.params.targetTriple.getEnvironment() == llvm::Triple::Android) {
|
||||
args.push_back("-ldl");
|
||||
args.push_back("-lm");
|
||||
break;
|
||||
}
|
||||
args.push_back("-lrt");
|
||||
// fallthrough
|
||||
case llvm::Triple::Darwin:
|
||||
case llvm::Triple::MacOSX:
|
||||
|
|
|
@ -739,12 +739,12 @@ static void registerPredefinedTargetVersions() {
|
|||
}
|
||||
break;
|
||||
case llvm::Triple::Linux:
|
||||
VersionCondition::addPredefinedGlobalIdent("linux");
|
||||
VersionCondition::addPredefinedGlobalIdent("Posix");
|
||||
if (global.params.targetTriple.getEnvironment() == llvm::Triple::Android) {
|
||||
VersionCondition::addPredefinedGlobalIdent("Android");
|
||||
VersionCondition::addPredefinedGlobalIdent("CRuntime_Bionic");
|
||||
} else {
|
||||
VersionCondition::addPredefinedGlobalIdent("linux");
|
||||
VersionCondition::addPredefinedGlobalIdent("Posix");
|
||||
VersionCondition::addPredefinedGlobalIdent("CRuntime_Glibc");
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -935,7 +935,8 @@ static void genModuleInfo(Module *m, bool emitFullModuleInfo) {
|
|||
b.finalize(moduleInfoSym->getType()->getPointerElementType(), moduleInfoSym);
|
||||
setLinkage({LLGlobalValue::ExternalLinkage, false}, moduleInfoSym);
|
||||
|
||||
if (global.params.targetTriple.isOSLinux() ||
|
||||
if ((global.params.targetTriple.isOSLinux() &&
|
||||
global.params.targetTriple.getEnvironment() != llvm::Triple::Android) ||
|
||||
global.params.targetTriple.isOSFreeBSD() ||
|
||||
#if LDC_LLVM_VER > 305
|
||||
global.params.targetTriple.isOSNetBSD() ||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue