Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mold: fatal: could not open plugin file: Cannot open "/usr/bin/../lib/LLVMgold.so" #793

Closed
rozhuk-im opened this issue Oct 18, 2022 · 16 comments

Comments

@rozhuk-im
Copy link

This happen on FreeBSD 13 amd64 during try to build svt-av1 with LTO.
There is no LLVMgold.so in system and system clang/ld work without this.

I suppose mold should not fail and silently ignore this.

@rui314
Copy link
Owner

rui314 commented Oct 18, 2022

I don't think this is a bug of mold. That path is not hardcoded to mold, so someone must be passing to the linker in your environment.

@rozhuk-im
Copy link
Author

clang do that, IMHO.
cc call linker, ld from clang does not fail on LLVMgold.so miss.
mold threat this as error and does not work.

FAILED: /tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Bin/Release/libSvtAv1Dec.so.0.8.7 
: && /usr/local/libexec/ccache/cc -fPIC -fno-stack-clash-protection -Wall -Wextra -Wformat -Wformat-security -O2 -pipe -O3 -pipe -funroll-loops -mretpoline  -fstack-protector-strong -fno-strict-aliasing  -fdebug-prefix-map=/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847=. -fstack-protector-strong -mno-avx -O2 -pipe -O3 -pipe -funroll-loops -mretpoline  -fstack-protector-strong -fno-strict-aliasing  -fdebug-prefix-map=/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847=. -flto=thin  '-fuse-ld=mold' -fstack-protector-strong -shared -Wl,-soname,libSvtAv1Dec.so.0 -o /tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Bin/Release/libSvtAv1Dec.so.0.8.7 Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbBitstreamUnit.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbBlend_a64_mask.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbBlockStructures.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbCabacContextModel.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbCdef.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbDeblockingCommon.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbInterPrediction.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbIntraPrediction.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbInvTransforms.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbLog.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbMalloc.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbMcp.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbPictureBufferDesc.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbPictureOperators.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbRestoration.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbSegmentationParams.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbSuperRes.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbSystemResourceManager.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbThreads.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbTime.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbUtility.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbWarpedMotion.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/common_dsp_rtcd.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/convolve.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/grainSynthesis.c.o third_party/fastfeat/CMakeFiles/FASTFEAT.dir/fast.c.o third_party/fastfeat/CMakeFiles/FASTFEAT.dir/fast_9.c.o third_party/fastfeat/CMakeFiles/FASTFEAT.dir/nonmax.c.o Source/Lib/Common/C_DEFAULT/CMakeFiles/COMMON_C_DEFAULT.dir/EbBlend_a64_mask_c.c.o Source/Lib/Common/C_DEFAULT/CMakeFiles/COMMON_C_DEFAULT.dir/EbInterPrediction_c.c.o Source/Lib/Common/C_DEFAULT/CMakeFiles/COMMON_C_DEFAULT.dir/EbIntraPrediction_c.c.o Source/Lib/Common/C_DEFAULT/CMakeFiles/COMMON_C_DEFAULT.dir/EbPackUnPack_C.c.o Source/Lib/Common/C_DEFAULT/CMakeFiles/COMMON_C_DEFAULT.dir/EbPictureOperators_C.c.o Source/Lib/Common/C_DEFAULT/CMakeFiles/COMMON_C_DEFAULT.dir/cfl_c.c.o Source/Lib/Common/C_DEFAULT/CMakeFiles/COMMON_C_DEFAULT.dir/filterintra_c.c.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/EbAvcStyleMcp_Intrinsic_SSE2.c.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/EbDeblockingFilter_Intrinsic_SSE2.c.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/EbIntraPrediction_AV1_Intrinsic_SSE2.c.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/EbPackUnPack_Intrinsic_SSE2.c.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/EbPictureOperators_Intrinsic_SSE2.c.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/convolve_2d_sse2.c.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/convolve_sse2.c.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/highbd_intrapred_sse2.c.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/highbd_subtract_sse2.c.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/jnt_convolve_2d_sse2.c.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/jnt_convolve_sse2.c.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/wiener_convolve_sse2.c.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/intrapred_sse2.asm.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/EbPictureOperators_SSE2.asm.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/highbd_intrapred_sse2_.asm.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/aom_subpixel_8t_sse2.asm.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/subtract_sse2.asm.o Source/Lib/Common/ASM_SSSE3/CMakeFiles/COMMON_ASM_SSSE3.dir/EbHighbdIntraPrediction_Intrinsic_SSSE3.c.o Source/Lib/Common/ASM_SSSE3/CMakeFiles/COMMON_ASM_SSSE3.dir/aom_subpixel_8t_intrin_ssse3.c.o Source/Lib/Common/ASM_SSSE3/CMakeFiles/COMMON_ASM_SSSE3.dir/av1_inv_txfm_ssse3.c.o Source/Lib/Common/ASM_SSSE3/CMakeFiles/COMMON_ASM_SSSE3.dir/highbd_convolve_2d_ssse3.c.o Source/Lib/Common/ASM_SSSE3/CMakeFiles/COMMON_ASM_SSSE3.dir/highbd_convolve_ssse3.c.o Source/Lib/Common/ASM_SSSE3/CMakeFiles/COMMON_ASM_SSSE3.dir/highbd_wiener_convolve_ssse3.c.o Source/Lib/Common/ASM_SSSE3/CMakeFiles/COMMON_ASM_SSSE3.dir/intrapred_ssse3.c.o Source/Lib/Common/ASM_SSSE3/CMakeFiles/COMMON_ASM_SSSE3.dir/jnt_convolve_ssse3.c.o Source/Lib/Common/ASM_SSSE3/CMakeFiles/COMMON_ASM_SSSE3.dir/reconinter_ssse3.c.o Source/Lib/Common/ASM_SSSE3/CMakeFiles/COMMON_ASM_SSSE3.dir/aom_subpixel_bilinear_ssse3.asm.o Source/Lib/Common/ASM_SSSE3/CMakeFiles/COMMON_ASM_SSSE3.dir/aom_subpixel_8t_ssse3.asm.o Source/Lib/Common/ASM_SSE4_1/CMakeFiles/COMMON_ASM_SSE4_1.dir/EbBlend_a64_mask_sse4.c.o Source/Lib/Common/ASM_SSE4_1/CMakeFiles/COMMON_ASM_SSE4_1.dir/EbIntraPrediction16bit_Intrinsic_SSE4_1.c.o Source/Lib/Common/ASM_SSE4_1/CMakeFiles/COMMON_ASM_SSE4_1.dir/EbPictureOperators_Intrinsic_SSE4_1.c.o Source/Lib/Common/ASM_SSE4_1/CMakeFiles/COMMON_ASM_SSE4_1.dir/av1_convolve_scale_sse4.c.o Source/Lib/Common/ASM_SSE4_1/CMakeFiles/COMMON_ASM_SSE4_1.dir/cdef_block_sse4_1.c.o Source/Lib/Common/ASM_SSE4_1/CMakeFiles/COMMON_ASM_SSE4_1.dir/filterintra_sse4.c.o Source/Lib/Common/ASM_SSE4_1/CMakeFiles/COMMON_ASM_SSE4_1.dir/highbd_convolve_2d_sse4.c.o Source/Lib/Common/ASM_SSE4_1/CMakeFiles/COMMON_ASM_SSE4_1.dir/highbd_inv_txfm_sse4.c.o Source/Lib/Common/ASM_SSE4_1/CMakeFiles/COMMON_ASM_SSE4_1.dir/highbd_jnt_convolve_sse4.c.o Source/Lib/Common/ASM_SSE4_1/CMakeFiles/COMMON_ASM_SSE4_1.dir/reconinter_sse4.c.o Source/Lib/Common/ASM_SSE4_1/CMakeFiles/COMMON_ASM_SSE4_1.dir/selfguided_sse4.c.o Source/Lib/Common/ASM_SSE4_1/CMakeFiles/COMMON_ASM_SSE4_1.dir/warp_plane_sse4.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/EbBlend_a64_mask_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/EbHighbdIntraPrediction_AVX2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/EbInterPredictionCom_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/EbIntraPrediction_Intrinsic_AVX2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/EbPackUnPack_Intrinsic_AVX2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/EbPictureOperators_Intrinsic_AVX2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/aom_subpixel_8t_intrin_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/av1_inv_txfm_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/cdef_block_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/cfl_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/convolve_2d_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/convolve_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/highbd_convolve_2d_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/highbd_convolve_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/highbd_inv_txfm_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/highbd_jnt_convolve_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/highbd_warp_affine_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/jnt_convolve_2d_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/jnt_convolve_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/selfguided_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/warp_plane_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/wiener_convolve_avx2.c.o Source/Lib/Common/ASM_AVX512/CMakeFiles/COMMON_ASM_AVX512.dir/EbHighbdIntraPrediction_AVX512.c.o Source/Lib/Common/ASM_AVX512/CMakeFiles/COMMON_ASM_AVX512.dir/EbPictureOperators_Intrinsic_AVX512.c.o Source/Lib/Common/ASM_AVX512/CMakeFiles/COMMON_ASM_AVX512.dir/cdef_block_avx512.c.o Source/Lib/Common/ASM_AVX512/CMakeFiles/COMMON_ASM_AVX512.dir/convolve_2d_avx512.c.o Source/Lib/Common/ASM_AVX512/CMakeFiles/COMMON_ASM_AVX512.dir/convolve_avx512.c.o Source/Lib/Common/ASM_AVX512/CMakeFiles/COMMON_ASM_AVX512.dir/highbd_inv_txfm_avx512.c.o Source/Lib/Common/ASM_AVX512/CMakeFiles/COMMON_ASM_AVX512.dir/jnt_convolve_2d_avx512.c.o Source/Lib/Common/ASM_AVX512/CMakeFiles/COMMON_ASM_AVX512.dir/jnt_convolve_avx512.c.o Source/Lib/Common/ASM_AVX512/CMakeFiles/COMMON_ASM_AVX512.dir/wiener_convolve_avx512.c.o third_party/cpuinfo/CMakeFiles/cpuinfo.dir/src/init.c.o third_party/cpuinfo/CMakeFiles/cpuinfo.dir/src/api.c.o third_party/cpuinfo/CMakeFiles/cpuinfo.dir/src/x86/x86_init.c.o third_party/cpuinfo/CMakeFiles/cpuinfo.dir/src/x86/vendor.c.o third_party/cpuinfo/CMakeFiles/cpuinfo.dir/src/x86/isa.c.o third_party/cpuinfo/CMakeFiles/cpuinfo.dir/src/x86/bsd/init.c.o third_party/cpuinfo/deps/clog/CMakeFiles/clog.dir/src/clog.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecBitstream.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecBitstreamUnit.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecCdef.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecHandle.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecInterPrediction.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecIntraPrediction.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecInverseQuantize.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecLF.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecMemInit.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecNbr.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecObmc.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecParseBlock.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecParseFrame.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecParseHelper.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecParseInterBlock.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecParseObu.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecPicMgr.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecProcess.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecProcessBlock.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecProcessFrame.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecRestoration.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecSuperRes.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecUtils.c.o -L/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/C_DEFAULT   -L/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/Codec   -L/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Decoder/Codec   -L/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/third_party/fastfeat   -L/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/ASM_SSE2   -L/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/ASM_SSSE3   -L/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/ASM_SSE4_1   -L/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/ASM_AVX2   -L/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/ASM_AVX512 -Wl,-rpath,/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/C_DEFAULT:/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/Codec:/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Decoder/Codec:/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/third_party/fastfeat:/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/ASM_SSE2:/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/ASM_SSSE3:/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/ASM_SSE4_1:/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/ASM_AVX2:/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/ASM_AVX512:  -lm  -lpthread && :
mold: fatal: could not open plugin file: Cannot open "/usr/bin/../lib/LLVMgold.so"
cc: error: linker command failed with exit code 1 (use -v to see invocation)

@rui314
Copy link
Owner

rui314 commented Oct 19, 2022

Even if lld completely ignores the -plugin option, specifying a nonexistent file as a linker plugin is a bug of clang. Please report it to FreeBSD clang package.

@rozhuk-im
Copy link
Author

This is clang specific, not FreeBSD.

You can find this in llvm upstream: clang/lib/Driver/ToolChains/CommonArgs.cpp

...
void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
                          ArgStringList &CmdArgs, const InputInfo &Output,
                          const InputInfo &Input, bool IsThinLTO) {
  const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath());
  const Driver &D = ToolChain.getDriver();
  if (llvm::sys::path::filename(Linker) != "ld.lld" &&
      llvm::sys::path::stem(Linker) != "ld.lld") {
    // Tell the linker to load the plugin. This has to come before
    // AddLinkerInputs as gold requires -plugin to come before any -plugin-opt
    // that -Wl might forward.
    CmdArgs.push_back("-plugin");

#if defined(_WIN32)
    const char *Suffix = ".dll";
#elif defined(__APPLE__)
    const char *Suffix = ".dylib";
#else
    const char *Suffix = ".so";
#endif

    SmallString<1024> Plugin;
    llvm::sys::path::native(
        Twine(D.Dir) + "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold" + Suffix,
        Plugin);
    CmdArgs.push_back(Args.MakeArgString(Plugin));
  }

  // Try to pass driver level flags relevant to LTO code generation down to
  // the plugin.

  // Handle flags for selecting CPU variants.
  std::string CPU = getCPUName(Args, ToolChain.getTriple());
  if (!CPU.empty())
    CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=mcpu=") + CPU));
...

So LTO should be broken on linux too then clang used.

@rui314
Copy link
Owner

rui314 commented Oct 19, 2022

No, it's actually a FreeBSD's clang package issue. LTO works on Linux with Clang. The problem is that FreeBSD's Clang doesn't ship with LLVMgold.so.

@rozhuk-im
Copy link
Author

You assume that LLVMgold.so should exist, this is not correct, it is an option that enabled by some maintainer on your linux distro.
I can build clang from ports and there is an option to enable/disable this and many other things.

CLang have workaround for this then ld.lld is used.

@rui314
Copy link
Owner

rui314 commented Oct 19, 2022

We do not assume that LLVMgold.so always exists. We assume that whatever file explicitly given as an argument for -plugin exists, which is a reasonable behavior. There's no point for a compiler driver to specify a nonexistent path as an argument for -plugin. Instead of letting a compiler driver to pass an erroneous command line parameter and letting a linker to ignore it, we should fix it on the producer side.

@ishitatsuyuki
Copy link
Contributor

ishitatsuyuki commented Oct 19, 2022

FWIW, The reason lld doesn't get -plugin is because it has clang LTO support built-in, as a part of the LLVM umbrella. It's not a "workaround".

@rozhuk-im
Copy link
Author

rozhuk-im commented Oct 19, 2022

I made patch to llvm, rebuild and reinstall it:

diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/CommonArgs.cpp b/contrib/llvm-project/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 8f9244cae8d..a91b4312947 100644
--- a/contrib/llvm-project/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -490,8 +490,6 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
     // Tell the linker to load the plugin. This has to come before
     // AddLinkerInputs as gold requires -plugin to come before any -plugin-opt
     // that -Wl might forward.
-    CmdArgs.push_back("-plugin");
-
 #if defined(_WIN32)
     const char *Suffix = ".dll";
 #elif defined(__APPLE__)
@@ -504,6 +502,9 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
     llvm::sys::path::native(
         Twine(D.Dir) + "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold" + Suffix,
         Plugin);
+    if (!llvm::sys::fs::exists(Plugin))
+        return;
+    CmdArgs.push_back("-plugin");
     CmdArgs.push_back(Args.MakeArgString(Plugin));
   }
 

now I get:

FAILED: /tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Bin/Release/libSvtAv1Dec.so.0.8.7 
: && /usr/local/libexec/ccache/cc -fPIC -fno-stack-clash-protection -Wall -Wextra -Wformat -Wformat-security -O2 -pipe -O3 -pipe -funroll-loops -mretpoline  -fstack-protector-strong -fno-strict-aliasing  -fdebug-prefix-map=/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847=. -fstack-protector-strong -mno-avx -O2 -pipe -O3 -pipe -funroll-loops -mretpoline  -fstack-protector-strong -fno-strict-aliasing  -fdebug-prefix-map=/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847=. -flto=thin  '-fuse-ld=mold' -fstack-protector-strong -shared -Wl,-soname,libSvtAv1Dec.so.0 -o /tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Bin/Release/libSvtAv1Dec.so.0.8.7 Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbBitstreamUnit.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbBlend_a64_mask.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbBlockStructures.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbCabacContextModel.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbCdef.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbDeblockingCommon.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbInterPrediction.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbIntraPrediction.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbInvTransforms.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbLog.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbMalloc.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbMcp.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbPictureBufferDesc.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbPictureOperators.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbRestoration.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbSegmentationParams.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbSuperRes.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbSystemResourceManager.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbThreads.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbTime.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbUtility.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbWarpedMotion.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/common_dsp_rtcd.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/convolve.c.o Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/grainSynthesis.c.o third_party/fastfeat/CMakeFiles/FASTFEAT.dir/fast.c.o third_party/fastfeat/CMakeFiles/FASTFEAT.dir/fast_9.c.o third_party/fastfeat/CMakeFiles/FASTFEAT.dir/nonmax.c.o Source/Lib/Common/C_DEFAULT/CMakeFiles/COMMON_C_DEFAULT.dir/EbBlend_a64_mask_c.c.o Source/Lib/Common/C_DEFAULT/CMakeFiles/COMMON_C_DEFAULT.dir/EbInterPrediction_c.c.o Source/Lib/Common/C_DEFAULT/CMakeFiles/COMMON_C_DEFAULT.dir/EbIntraPrediction_c.c.o Source/Lib/Common/C_DEFAULT/CMakeFiles/COMMON_C_DEFAULT.dir/EbPackUnPack_C.c.o Source/Lib/Common/C_DEFAULT/CMakeFiles/COMMON_C_DEFAULT.dir/EbPictureOperators_C.c.o Source/Lib/Common/C_DEFAULT/CMakeFiles/COMMON_C_DEFAULT.dir/cfl_c.c.o Source/Lib/Common/C_DEFAULT/CMakeFiles/COMMON_C_DEFAULT.dir/filterintra_c.c.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/EbAvcStyleMcp_Intrinsic_SSE2.c.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/EbDeblockingFilter_Intrinsic_SSE2.c.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/EbIntraPrediction_AV1_Intrinsic_SSE2.c.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/EbPackUnPack_Intrinsic_SSE2.c.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/EbPictureOperators_Intrinsic_SSE2.c.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/convolve_2d_sse2.c.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/convolve_sse2.c.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/highbd_intrapred_sse2.c.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/highbd_subtract_sse2.c.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/jnt_convolve_2d_sse2.c.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/jnt_convolve_sse2.c.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/wiener_convolve_sse2.c.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/intrapred_sse2.asm.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/EbPictureOperators_SSE2.asm.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/highbd_intrapred_sse2_.asm.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/aom_subpixel_8t_sse2.asm.o Source/Lib/Common/ASM_SSE2/CMakeFiles/COMMON_ASM_SSE2.dir/subtract_sse2.asm.o Source/Lib/Common/ASM_SSSE3/CMakeFiles/COMMON_ASM_SSSE3.dir/EbHighbdIntraPrediction_Intrinsic_SSSE3.c.o Source/Lib/Common/ASM_SSSE3/CMakeFiles/COMMON_ASM_SSSE3.dir/aom_subpixel_8t_intrin_ssse3.c.o Source/Lib/Common/ASM_SSSE3/CMakeFiles/COMMON_ASM_SSSE3.dir/av1_inv_txfm_ssse3.c.o Source/Lib/Common/ASM_SSSE3/CMakeFiles/COMMON_ASM_SSSE3.dir/highbd_convolve_2d_ssse3.c.o Source/Lib/Common/ASM_SSSE3/CMakeFiles/COMMON_ASM_SSSE3.dir/highbd_convolve_ssse3.c.o Source/Lib/Common/ASM_SSSE3/CMakeFiles/COMMON_ASM_SSSE3.dir/highbd_wiener_convolve_ssse3.c.o Source/Lib/Common/ASM_SSSE3/CMakeFiles/COMMON_ASM_SSSE3.dir/intrapred_ssse3.c.o Source/Lib/Common/ASM_SSSE3/CMakeFiles/COMMON_ASM_SSSE3.dir/jnt_convolve_ssse3.c.o Source/Lib/Common/ASM_SSSE3/CMakeFiles/COMMON_ASM_SSSE3.dir/reconinter_ssse3.c.o Source/Lib/Common/ASM_SSSE3/CMakeFiles/COMMON_ASM_SSSE3.dir/aom_subpixel_bilinear_ssse3.asm.o Source/Lib/Common/ASM_SSSE3/CMakeFiles/COMMON_ASM_SSSE3.dir/aom_subpixel_8t_ssse3.asm.o Source/Lib/Common/ASM_SSE4_1/CMakeFiles/COMMON_ASM_SSE4_1.dir/EbBlend_a64_mask_sse4.c.o Source/Lib/Common/ASM_SSE4_1/CMakeFiles/COMMON_ASM_SSE4_1.dir/EbIntraPrediction16bit_Intrinsic_SSE4_1.c.o Source/Lib/Common/ASM_SSE4_1/CMakeFiles/COMMON_ASM_SSE4_1.dir/EbPictureOperators_Intrinsic_SSE4_1.c.o Source/Lib/Common/ASM_SSE4_1/CMakeFiles/COMMON_ASM_SSE4_1.dir/av1_convolve_scale_sse4.c.o Source/Lib/Common/ASM_SSE4_1/CMakeFiles/COMMON_ASM_SSE4_1.dir/cdef_block_sse4_1.c.o Source/Lib/Common/ASM_SSE4_1/CMakeFiles/COMMON_ASM_SSE4_1.dir/filterintra_sse4.c.o Source/Lib/Common/ASM_SSE4_1/CMakeFiles/COMMON_ASM_SSE4_1.dir/highbd_convolve_2d_sse4.c.o Source/Lib/Common/ASM_SSE4_1/CMakeFiles/COMMON_ASM_SSE4_1.dir/highbd_inv_txfm_sse4.c.o Source/Lib/Common/ASM_SSE4_1/CMakeFiles/COMMON_ASM_SSE4_1.dir/highbd_jnt_convolve_sse4.c.o Source/Lib/Common/ASM_SSE4_1/CMakeFiles/COMMON_ASM_SSE4_1.dir/reconinter_sse4.c.o Source/Lib/Common/ASM_SSE4_1/CMakeFiles/COMMON_ASM_SSE4_1.dir/selfguided_sse4.c.o Source/Lib/Common/ASM_SSE4_1/CMakeFiles/COMMON_ASM_SSE4_1.dir/warp_plane_sse4.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/EbBlend_a64_mask_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/EbHighbdIntraPrediction_AVX2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/EbInterPredictionCom_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/EbIntraPrediction_Intrinsic_AVX2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/EbPackUnPack_Intrinsic_AVX2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/EbPictureOperators_Intrinsic_AVX2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/aom_subpixel_8t_intrin_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/av1_inv_txfm_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/cdef_block_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/cfl_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/convolve_2d_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/convolve_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/highbd_convolve_2d_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/highbd_convolve_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/highbd_inv_txfm_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/highbd_jnt_convolve_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/highbd_warp_affine_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/jnt_convolve_2d_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/jnt_convolve_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/selfguided_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/warp_plane_avx2.c.o Source/Lib/Common/ASM_AVX2/CMakeFiles/COMMON_ASM_AVX2.dir/wiener_convolve_avx2.c.o Source/Lib/Common/ASM_AVX512/CMakeFiles/COMMON_ASM_AVX512.dir/EbHighbdIntraPrediction_AVX512.c.o Source/Lib/Common/ASM_AVX512/CMakeFiles/COMMON_ASM_AVX512.dir/EbPictureOperators_Intrinsic_AVX512.c.o Source/Lib/Common/ASM_AVX512/CMakeFiles/COMMON_ASM_AVX512.dir/cdef_block_avx512.c.o Source/Lib/Common/ASM_AVX512/CMakeFiles/COMMON_ASM_AVX512.dir/convolve_2d_avx512.c.o Source/Lib/Common/ASM_AVX512/CMakeFiles/COMMON_ASM_AVX512.dir/convolve_avx512.c.o Source/Lib/Common/ASM_AVX512/CMakeFiles/COMMON_ASM_AVX512.dir/highbd_inv_txfm_avx512.c.o Source/Lib/Common/ASM_AVX512/CMakeFiles/COMMON_ASM_AVX512.dir/jnt_convolve_2d_avx512.c.o Source/Lib/Common/ASM_AVX512/CMakeFiles/COMMON_ASM_AVX512.dir/jnt_convolve_avx512.c.o Source/Lib/Common/ASM_AVX512/CMakeFiles/COMMON_ASM_AVX512.dir/wiener_convolve_avx512.c.o third_party/cpuinfo/CMakeFiles/cpuinfo.dir/src/init.c.o third_party/cpuinfo/CMakeFiles/cpuinfo.dir/src/api.c.o third_party/cpuinfo/CMakeFiles/cpuinfo.dir/src/x86/x86_init.c.o third_party/cpuinfo/CMakeFiles/cpuinfo.dir/src/x86/vendor.c.o third_party/cpuinfo/CMakeFiles/cpuinfo.dir/src/x86/isa.c.o third_party/cpuinfo/CMakeFiles/cpuinfo.dir/src/x86/bsd/init.c.o third_party/cpuinfo/deps/clog/CMakeFiles/clog.dir/src/clog.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecBitstream.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecBitstreamUnit.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecCdef.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecHandle.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecInterPrediction.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecIntraPrediction.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecInverseQuantize.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecLF.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecMemInit.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecNbr.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecObmc.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecParseBlock.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecParseFrame.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecParseHelper.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecParseInterBlock.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecParseObu.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecPicMgr.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecProcess.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecProcessBlock.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecProcessFrame.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecRestoration.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecSuperRes.c.o Source/Lib/Decoder/CMakeFiles/SvtAv1Dec.dir/Codec/EbDecUtils.c.o -L/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/C_DEFAULT   -L/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/Codec   -L/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Decoder/Codec   -L/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/third_party/fastfeat   -L/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/ASM_SSE2   -L/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/ASM_SSSE3   -L/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/ASM_SSE4_1   -L/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/ASM_AVX2   -L/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/ASM_AVX512 -Wl,-rpath,/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/C_DEFAULT:/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/Codec:/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Decoder/Codec:/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/third_party/fastfeat:/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/ASM_SSE2:/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/ASM_SSSE3:/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/ASM_SSE4_1:/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/ASM_AVX2:/tmp/ports/usr/ports/multimedia/svt-av1/work/SVT-AV1-6e24fb7f5f7438bb04061dc1a159f0c5b882d847/Source/Lib/Common/ASM_AVX512:  -lm  -lpthread && :
mold: fatal: Source/Lib/Common/Codec/CMakeFiles/COMMON_CODEC.dir/EbBitstreamUnit.c.o: don't know how to handle this LTO object file because no -plugin option was given. Please make sure you added -flto not only for creating object files but also for creating the final executable.
cc: error: linker command failed with exit code 1 (use -v to see invocation)

PS: then I create symlynk to LLVMgold.so (llvm13 installed from ports with this plugin, base llvm is 13 too) then it link in single thread, do not see performace grow.

@ishitatsuyuki
Copy link
Contributor

ishitatsuyuki commented Oct 19, 2022

  1. You can't do LTO in non-LLD linkers without the plugin. If you pass -flto, you need LLVMgold.so.
  2. If you are using -flto (and not -flto=thin) then the bulk of time is spent inside the compiler code doing single-threaded Link-Time Optimization. mold cannot make this magically fast. For parallel LTO, look for ThinLTO.

@rozhuk-im
Copy link
Author

I am right that it: "work as intended" / "not a bug" ?

LTO enabled on build system side, clang add LLVMgold.so, mold fail because no LLVMgold.so.
In any way mold requires plugin to handle LTO.

@rui314
Copy link
Owner

rui314 commented Oct 19, 2022

You are right. mold is working as intended. Any linker other than lld can't do LTO without the linker plugin file. (On the other hand, lld can't do LTO with a linker plugin, so it can't do LTO with any compilers other than clang.)

@rui314 rui314 closed this as completed Oct 19, 2022
@rui314
Copy link
Owner

rui314 commented Oct 19, 2022

Please file a bug to FreeBSD clang package so that

  • if LLVMgold.so is missing, do not pass it as an argument for -plugin, and
  • include LLVMgold.so into the FreeBSD's clang package.

@rozhuk-im
Copy link
Author

  1. clang is a part of system
  2. LLVMgold.so not included because of incompatible license
  3. Clang pass -plugin LLVMgold.so if LTO is enabled, if use patch to prevent this then build will fail.
  4. Better to document this case some where in mold man/docs/faq, it is clang specific, not FreeBSD.

@rui314
Copy link
Owner

rui314 commented Oct 20, 2022

As I said, this is a problem of clang that invokes a linker with a bad parameter. It is not a linker but clang who should print out an error message if -flto is passed but the linker is not ld.lld and there's no LLVMgold.so. This problem is not specific to mold; you should get the same error for any linker other than ld.lld (e.g. GNU ld).

@rui314
Copy link
Owner

rui314 commented Oct 20, 2022

I recommended you report this issue to FreeBSD because they need a user input to fix the issue once and for all. There's actually a fix to this issue which I made in May (https://reviews.llvm.org/D125624), but there's no progress because there's no one who pushed it other than me. Your problem cannot be solved by filing a bug to mold and pushing me to do something. Please file bugs to FreeBSD and Clang instead and ask them to solve the problem for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants