Skip to content

Commit

Permalink
fix build issues and include path on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Zach DeVito committed Aug 4, 2015
1 parent 69eac1b commit 84bbb0b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/tcompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ static void InitializeJIT(TerraCompilationUnit * CU) {
if(CU->ee) return; //already initialized
Module * topeemodule = (CU->T->options.usemcjit) ? new Module("terra",*CU->TT->ctx) : CU->M;
#ifdef _WIN32
std::string MCJITTriple = CU->Triple;
std::string MCJITTriple = CU->TT->Triple;
MCJITTriple.append("-elf"); //on windows we need to use an elf container because coff is not supported yet
topeemodule->setTargetTriple(MCJITTriple);
#else
Expand Down Expand Up @@ -787,7 +787,7 @@ struct CCallingConv {
#else
Type * TypeForClass(size_t size, RegisterClass clz) {
assert(size <= 8);
return Type::getIntNTy(*C->ctx, size * 8);
return Type::getIntNTy(*CU->TT->ctx, size * 8);
}
bool ValidAggregateSize(size_t sz) {
bool isPow2 = sz && !(sz & (sz - 1));
Expand Down Expand Up @@ -847,7 +847,7 @@ struct CCallingConv {
//to be translated to void. So if it is unit, force the return value to be void by overriding the normal
//classification decision
if(Ty->IsUnitType(&returntype)) {
info->returntype = Argument(C_AGGREGATE_REG,info->returntype.type,StructType::get(*C->ctx));
info->returntype = Argument(C_AGGREGATE_REG,info->returntype.type,StructType::get(*CU->TT->ctx));
}
#endif

Expand Down
10 changes: 7 additions & 3 deletions src/terralib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ function terra.newtarget(tbl)
Features = Features or ""
end
return setmetatable({ llvm_target = cdatawithdestructor(terra.inittarget(Triple,CPU,Features,FloatABIHard),terra.freetarget),
Triple = Triple,
cnametostruct = { general = {}, tagged = {}} --map from llvm_name -> terra type used to make c structs unique per llvm_name
},terra.target)
end
Expand Down Expand Up @@ -3645,8 +3646,12 @@ end

function terra.includecstring(code,cargs,target)
local args = terra.newlist {"-O3","-Wno-deprecated","-resource-dir",clangresourcedirectory}
args:insert("-internal-isystem")
args:insert(clangresourcedirectory.."/include")
target = target or terra.nativetarget

if (target == terra.nativetarget and ffi.os == "Linux") or (target.Triple and target.Triple:match("linux")) then
args:insert("-internal-isystem")
args:insert(clangresourcedirectory.."/include")
end

if cargs then
args:insertall(cargs)
Expand All @@ -3655,7 +3660,6 @@ function terra.includecstring(code,cargs,target)
args:insert("-I")
args:insert(p)
end
target = target or terra.nativetarget
assert(terra.istarget(target),"expected a target or nil to specify the native target")
local result = terra.registercfile(target,code,args,headerprovider)
local general,tagged,errors,macros = result.general,result.tagged,result.errors,result.macros
Expand Down

0 comments on commit 84bbb0b

Please sign in to comment.