Chosing a specific CLANG version out of multiple installations

Hi, trying to build on a Gentoo based system, GCC fails due to missing the graphite flag.
I try to build it with LLVM/CLANG 15, still fails.
Now, I have two LLVM/CLANG versions, 14 & 15.
How would I make DT build with LLVM/CLANG 14 instead of the latest detected version (15)?

Thanks.

Hi @msdobrescu,

I am on a bit of thin ice here, but…

a) What “gentoo based” system are you using?
b) What version of gcc?
c) I presume you have tried to add USE flag “graphite”?

Have fun!
Claes in Lund, Sweden

MocaccinoOS (https://www.mocaccino.org/).
We avoided graphite, as this brings some complications and DT is the only one needing that flag.
Anyway, now we moved to LLVM/CLANG 15, but we try to use 14 along with it, as a test.
Under CLANG 15 DT build fails with clang-15: error: linker command failed with exit code 1.

I think the relevant part is:

       `fast_surface_blur.ifunc' referenced in section `.text' of bin/CMakeFiles/lib_darktable.dir/views/view.c.o: defined in discarded section `.text.fast_surface_blur.resolver[fast_surface_blur.resolver]' of bin/CMakeFiles/lib_darktable.dir/views/view.c.o
       `interpolate_bilinear.ifunc' referenced in section `.text' of bin/CMakeFiles/lib_darktable.dir/views/view.c.o: defined in discarded section `.text.interpolate_bilinear.resolver[interpolate_bilinear.resolver]' of bin/CMakeFiles/lib_darktable.dir/views/view.c.o
       `quantize.ifunc' referenced in section `.text' of bin/CMakeFiles/lib_darktable.dir/views/view.c.o: defined in discarded section `.text.quantize.resolver[quantize.resolver]' of bin/CMakeFiles/lib_darktable.dir/views/view.c.o
       `variance_analyse.ifunc' referenced in section `.text' of bin/CMakeFiles/lib_darktable.dir/views/view.c.o: defined in discarded section `.text.variance_analyse.resolver[variance_analyse.resolver]' of bin/CMakeFiles/lib_darktable.dir/views/view.c.o
       `apply_linear_blending.ifunc' referenced in section `.text' of bin/CMakeFiles/lib_darktable.dir/views/view.c.o: defined in discarded section `.text.apply_linear_blending.resolver[apply_linear_blending.resolver]' of bin/CMakeFiles/lib_darktable.dir/views/view.c.o
       `apply_linear_blending_w_geomean.ifunc' referenced in section `.text' of bin/CMakeFiles/lib_darktable.dir/views/view.c.o: defined in discarded section `.text.apply_linear_blending_w_geomean.resolver[apply_linear_blending_w_geomean.resolver]' of bin/CMakeFiles/lib_darktable.dir/views/view.c.o
       `fast_clamp.ifunc' referenced in section `.text' of bin/CMakeFiles/lib_darktable.dir/views/view.c.o: defined in discarded section `.text.fast_clamp.resolver[fast_clamp.resolver]' of bin/CMakeFiles/lib_darktable.dir/views/view.c.o
       clang-15: error: linker command failed with exit code 1 (use -v to see invocation)
       ninja: build stopped: subcommand failed.

@LebedevRI is probably the correct person to comment on this.

JFYI openSUSE Tumbleweed builds with clang 15.0.7. which is kinda in the same boat as the other rolling release distributions.

Thanks! it would be interesting to see the package source code that does the build.

1 Like

Never seen that kind of issue.
Which linker is being used, LLD?

In Portage a profile is created and assigned to the package.
The profile looks like this:

COMMON_FLAGS="-march=x86-64 -O2 -pipe"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"

CC="clang"
CXX="clang++"
AR="llvm-ar"
NM="llvm-nm"
RANLIB="llvm-ranlib"

LDFLAGS="${LDFLAGS} -Wl,-O2 -Wl,--as-needed"```

I see, LLD + -DBINARY_PACKAGE_BUILD=ON is all it takes.
Same with ld.gold, so it’s LLVM bug that someone should report.

At the same time, it might be good to have a cmake option
to better control Unset target_clones attribute for -march=native build · darktable-org/darktable@4ba6413 · GitHub

Any other packages that use this profile build successfully. What makes DT not to?

But, to go to the original question, if there are both installed at a time, 14 & 15, is there a way to select only one? I see DT detects the latest all the time, which is 15, while I’d like to try 14.

Do any of them use __attribute__((target_clones(...))) feature?

The same way you’d normally switch compilers, via CC/CXX.
But it doesn’t work with LLVM14 either.

Not sure about that macro, but why does it build for Suse above?

Because it doesn’t:
https://build.opensuse.org/public/build/graphics:darktable/openSUSE_Tumbleweed/x86_64/darktable/_log

[   49s] -- The CXX compiler identification is GNU 12.2.1
[   49s] -- The C compiler identification is GNU 12.2.1

OK, thanks for clarifying this!

I’ve filed CI coverage issues · Issue #13583 · darktable-org/darktable · GitHub
This really should be fixed on darktable’s side (point 2.).

On top of this, would be there a graphite flag equivalent for clang? If not, would be there a way to disable it for gcc too?

https://polly.llvm.org/docs/UsingPollyWithClang.html i guess,
though i have absolutely no idea about the either of the two.

openSUSE does not build with march=native.

That would be not so generic.

I’ve found this: ports - FreeBSD ports tree

It claims it’s possible to disable/remove the graphite optimizations. I could not build with that either or I missed something.

Would be truly nice to have the possibility to disable all these to be able to build it without graphite.