-fvisibility=hidden: Only hide function *definitions*, don't touch declarations (#2923)

This commit is contained in:
Martin Kinkelin 2018-12-03 20:59:59 +01:00 committed by GitHub
parent 7966987178
commit deaaab8cf3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 73 additions and 59 deletions

View file

@ -574,13 +574,6 @@ void DtoDeclareFunction(FuncDeclaration *fdecl) {
: LLGlobalValue::DLLExportStorageClass);
}
// Hide non-exported symbols
if (opts::defaultToHiddenVisibility &&
!fdecl->isImportedSymbol() &&
!fdecl->isExport()) {
func->setVisibility(LLGlobalValue::HiddenVisibility);
}
IF_LOG Logger::cout() << "func = " << *func << std::endl;
// add func to IRFunc
@ -981,12 +974,6 @@ void DtoDefineFunction(FuncDeclaration *fd, bool linkageAvailableExternally) {
}
}
// if this function is naked, we take over right away! no standard processing!
if (fd->naked) {
DtoDefineNakedFunction(fd);
return;
}
if (!fd->fbody) {
return;
}
@ -1002,6 +989,16 @@ void DtoDefineFunction(FuncDeclaration *fd, bool linkageAvailableExternally) {
return;
}
if (opts::defaultToHiddenVisibility && !fd->isExport()) {
func->setVisibility(LLGlobalValue::HiddenVisibility);
}
// if this function is naked, we take over right away! no standard processing!
if (fd->naked) {
DtoDefineNakedFunction(fd);
return;
}
SCOPE_EXIT {
if (irFunc->isDynamicCompiled()) {
defineDynamicCompiledFunction(gIR, irFunc);