Skip to content

Commit

Permalink
Fix section names for OSX. Fixes #6.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Watanabe committed Mar 5, 2013
1 parent 012a884 commit 3a4e256
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
8 changes: 6 additions & 2 deletions lib/CodeGen/CGDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,12 @@ CodeGenFunction::CreateStaticVarDecl(const VarDecl &D,
GV->setAlignment(getContext().getDeclAlign(&D).getQuantity());
if (Linkage != llvm::GlobalValue::InternalLinkage)
GV->setVisibility(CurFn->getVisibility());
if(SharedInit)
GV->setSection("upc_shared");
if(SharedInit) {
if(CGM.isTargetDarwin())
GV->setSection("__DATA,upc_shared");
else
GV->setSection("upc_shared");
}
return GV;
}

Expand Down
6 changes: 5 additions & 1 deletion lib/CodeGen/CGStmtUPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ llvm::Constant *CodeGenModule::getUPCFenceVar() {
llvm::GlobalValue::LinkOnceODRLinkage,
llvm::ConstantInt::get(IntTy, 0),
"__upc_fence_var");
GV->setSection("upc_shared");

if(isTargetDarwin())
GV->setSection("__DATA,upc_shared");
else
GV->setSection("upc_shared");
UPCFenceVar = GV;
}
return UPCFenceVar;
Expand Down
13 changes: 10 additions & 3 deletions lib/CodeGen/CodeGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ void CodeGenModule::Release() {
true, llvm::GlobalValue::InternalLinkage,
llvm::ConstantDataArray::getString(getLLVMContext(), str),
"GCCUPCConfig");
conf->setSection("upc_pgm_info");
if(isTargetDarwin())
conf->setSection("__DATA,upc_pgm_info");
else
conf->setSection("upc_pgm_info");
AddUsedGlobal(conf);
}
EmitDeferred();
Expand Down Expand Up @@ -1654,8 +1657,12 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
GV->setConstant(false);

SetCommonAttributes(D, GV);
if(ASTTy.getQualifiers().hasShared())
GV->setSection("upc_shared");
if(ASTTy.getQualifiers().hasShared()) {
if(isTargetDarwin())
GV->setSection("__DATA,upc_shared");
else
GV->setSection("upc_shared");
}

// Emit the initializer function if necessary.
if (NeedsGlobalCtor || NeedsGlobalDtor)
Expand Down
8 changes: 7 additions & 1 deletion runtime/libupc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,18 @@ endforeach()

set_property(SOURCE ${LIBUPC_SOURCES} PROPERTY LANGUAGE C)

if(APPLE)
set(config_dir darwin)
else()
set(config_dir default)
endif()

macro(add_crt_target name opts)
set(obj ${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/${name}.o)
list(APPEND objects ${obj})
add_custom_target(${name} ALL DEPENDS ${obj})
add_custom_command(OUTPUT ${obj}
COMMAND ${CMAKE_C_COMPILER} -c -o ${obj} ${PROJECT_SOURCE_DIR}/upc-crtstuff.c -I${PROJECT_SOURCE_DIR}/config/default -I${PROJECT_BINARY_DIR} ${opts}
COMMAND ${CMAKE_C_COMPILER} -c -o ${obj} ${PROJECT_SOURCE_DIR}/upc-crtstuff.c -I${PROJECT_SOURCE_DIR}/config/${config_dir} -I${PROJECT_BINARY_DIR} ${opts}
MAIN_DEPENDENCY upc-crtstuff.c
IMPLICIT_DEPENDENCY upc-crtstuff.c
VERBATIM)
Expand Down

0 comments on commit 3a4e256

Please sign in to comment.