diff --git a/Make.inc b/Make.inc index cb062a46a68cb..47d35e01d2341 100644 --- a/Make.inc +++ b/Make.inc @@ -467,7 +467,7 @@ FC := $(CROSS_COMPILE)gfortran ifeq ($(OS), Darwin) APPLE_ARCH := $(shell uname -m) ifneq ($(APPLE_ARCH),arm64) -MACOSX_VERSION_MIN := 10.10 +MACOSX_VERSION_MIN := 10.14 else MACOSX_VERSION_MIN := 11.0 endif diff --git a/src/aotcompile.cpp b/src/aotcompile.cpp index 7c16d09399334..b4fd14b10c80b 100644 --- a/src/aotcompile.cpp +++ b/src/aotcompile.cpp @@ -936,6 +936,8 @@ struct ShardTimers { } }; +void emitFloat16Wrappers(Module &M, bool external); + // Perform the actual optimization and emission of the output files static void add_output_impl(Module &M, TargetMachine &SourceTM, std::string *outputs, ArrayRef names, NewArchiveMember *unopt, NewArchiveMember *opt, NewArchiveMember *obj, NewArchiveMember *asm_, @@ -1014,6 +1016,8 @@ static void add_output_impl(Module &M, TargetMachine &SourceTM, std::string *out FunctionType::get(Type::getHalfTy(M.getContext()), { Type::getFloatTy(M.getContext()) }, false)); injectCRTAlias(M, "__truncdfhf2", "julia__truncdfhf2", FunctionType::get(Type::getHalfTy(M.getContext()), { Type::getDoubleTy(M.getContext()) }, false)); +#else + emitFloat16Wrappers(M, false); #endif } timers.optimize.stopTimer(); diff --git a/src/codegen.cpp b/src/codegen.cpp index 31001b19e1d79..bcf7e25dab09c 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -8684,14 +8684,15 @@ static JuliaVariable *julia_const_gv(jl_value_t *val) return nullptr; } //Float16 fun -static void makeCastCall(Module &M, StringRef wrapperName, StringRef calledName, FunctionType *FTwrapper, FunctionType *FTcalled) +static void makeCastCall(Module &M, StringRef wrapperName, StringRef calledName, FunctionType *FTwrapper, FunctionType *FTcalled, bool external) { Function *calledFun = M.getFunction(calledName); if (!calledFun) { calledFun = Function::Create(FTcalled, Function::ExternalLinkage, calledName, M); } - auto wrapperFun = Function::Create(FTwrapper, Function::ExternalLinkage, wrapperName, M); - + auto linkage = external ? Function::ExternalLinkage : Function::InternalLinkage; + auto wrapperFun = Function::Create(FTwrapper, linkage, wrapperName, M); + wrapperFun->addFnAttr(Attribute::AlwaysInline); llvm::IRBuilder<> builder(BasicBlock::Create(M.getContext(), "top", wrapperFun)); SmallVector CallArgs; if (wrapperFun->arg_size() != calledFun->arg_size()){ @@ -8708,20 +8709,19 @@ static void makeCastCall(Module &M, StringRef wrapperName, StringRef calledName, builder.CreateRet(retval); } -static void emitFloat16Wrappers(Module &M) +void emitFloat16Wrappers(Module &M, bool external) { auto &ctx = M.getContext(); makeCastCall(M, "__gnu_h2f_ieee", "julia__gnu_h2f_ieee", FunctionType::get(Type::getFloatTy(ctx), { Type::getHalfTy(ctx) }, false), - FunctionType::get(Type::getFloatTy(ctx), { Type::getInt16Ty(ctx) }, false)); + FunctionType::get(Type::getFloatTy(ctx), { Type::getInt16Ty(ctx) }, false), external); makeCastCall(M, "__extendhfsf2", "julia__gnu_h2f_ieee", FunctionType::get(Type::getFloatTy(ctx), { Type::getHalfTy(ctx) }, false), - FunctionType::get(Type::getFloatTy(ctx), { Type::getInt16Ty(ctx) }, false)); + FunctionType::get(Type::getFloatTy(ctx), { Type::getInt16Ty(ctx) }, false), external); makeCastCall(M, "__gnu_f2h_ieee", "julia__gnu_f2h_ieee", FunctionType::get(Type::getHalfTy(ctx), { Type::getFloatTy(ctx) }, false), - FunctionType::get(Type::getInt16Ty(ctx), { Type::getFloatTy(ctx) }, false)); + FunctionType::get(Type::getInt16Ty(ctx), { Type::getFloatTy(ctx) }, false), external); makeCastCall(M, "__truncsfhf2", "julia__gnu_f2h_ieee", FunctionType::get(Type::getHalfTy(ctx), { Type::getFloatTy(ctx) }, false), - FunctionType::get(Type::getInt16Ty(ctx), { Type::getFloatTy(ctx) }, false)); + FunctionType::get(Type::getInt16Ty(ctx), { Type::getFloatTy(ctx) }, false), external); makeCastCall(M, "__truncdfhf2", "julia__truncdfhf2", FunctionType::get(Type::getHalfTy(ctx), { Type::getDoubleTy(ctx) }, false), - FunctionType::get(Type::getInt16Ty(ctx), { Type::getDoubleTy(ctx) }, false)); - + FunctionType::get(Type::getInt16Ty(ctx), { Type::getDoubleTy(ctx) }, false), external); } static void init_f16_funcs(void) @@ -8729,7 +8729,7 @@ static void init_f16_funcs(void) auto ctx = jl_ExecutionEngine->acquireContext(); auto TSM = jl_create_ts_module("F16Wrappers", ctx, imaging_default()); auto aliasM = TSM.getModuleUnlocked(); - emitFloat16Wrappers(*aliasM); + emitFloat16Wrappers(*aliasM, true); jl_ExecutionEngine->addModule(std::move(TSM)); } diff --git a/src/jitlayers.cpp b/src/jitlayers.cpp index eca9c429c8051..91579ddb3a796 100644 --- a/src/jitlayers.cpp +++ b/src/jitlayers.cpp @@ -1340,16 +1340,14 @@ JuliaOJIT::JuliaOJIT() } JD.addToLinkOrder(GlobalJD, orc::JITDylibLookupFlags::MatchExportedSymbolsOnly); -#if JL_LLVM_VERSION <= 140000 orc::SymbolAliasMap jl_crt = { - { mangle("__gnu_h2f_ieee"), { mangle("julia__gnu_h2f_ieee"), JITSymbolFlags::Exported } }, - { mangle("__extendhfsf2"), { mangle("julia__gnu_h2f_ieee"), JITSymbolFlags::Exported } }, - { mangle("__gnu_f2h_ieee"), { mangle("julia__gnu_f2h_ieee"), JITSymbolFlags::Exported } }, - { mangle("__truncsfhf2"), { mangle("julia__gnu_f2h_ieee"), JITSymbolFlags::Exported } }, - { mangle("__truncdfhf2"), { mangle("julia__truncdfhf2"), JITSymbolFlags::Exported } } + { mangle("__gnu_h2f_ieee"), { mangle("__jl_half2float"), JITSymbolFlags::Exported } }, + { mangle("__extendhfsf2"), { mangle("__jl_half2float"), JITSymbolFlags::Exported } }, + { mangle("__gnu_f2h_ieee"), { mangle("__jl_float2half"), JITSymbolFlags::Exported } }, + { mangle("__truncsfhf2"), { mangle("__jl_float2half"), JITSymbolFlags::Exported } }, + { mangle("__truncdfhf2"), { mangle("__jl_double2half"), JITSymbolFlags::Exported } } }; cantFail(GlobalJD.define(orc::symbolAliases(jl_crt))); -#endif #ifdef MSAN_EMUTLS_WORKAROUND orc::SymbolMap msan_crt;