Clang is always recompiling entire project when it's path is /bin/clang

Hello!

I’m experiencing the issue with clang from Manjaro’s repository. When clang is used from “/bin/clang” (“/bin” is a symlink to “/usr/bin”) entire project is recompiling every time. Example commands:

Wrong behavior when building project:

cmake -B build -S . -GNinja -DCMAKE_C_COMPILER=/bin/clang -DCMAKE_CXX_COMPILER=/bin/clang++

Good behavior when building project:

cmake -B build -S . -GNinja -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++

I noticed the problem since QtCreator 15.0.0 update, where it auto-detects clang kit from “/bin” path instead “/usr/bin” (it was “/usr/bin” in previous QtCreator versions).

Manjaro has both: “/usr/bin” and “/bin” in mentioned order in “PATH” which adds a symlink which can make duplicates when finding software. Also clang makes mistakes when it’s used from “/bin” symlink and causes recompilation of entire project on every build.

Steps to reproduce (as of 14-Dec-2024):

  • download and launch “manjaro-xfce-24.2.0-241209-linux612.iso”
  • install software “sudo pacman -Sy cmake ninja qtcreator clang”
  • run “qtcreator”
  • click Edit->Preferences->Kits
  • select “Desktop” Kit and change compiler from GCC to Clang and press OK
  • click “Create project”, use defaults (press Choose/Next/Finish)
  • press Ctrl+B to build
  • press Ctrl+B again

Result: Sources are building again, but it shouldn’t (we haven’t changed anything in the code).

When compiler will be set to “/usr/bin/clang” path - everything is working correctly.

GCC compiler seems to be working correctly from “/bin/gcc” (only Clang is affected).


I’ve already reported an issue to QtCreator JIRA, but developers recommended to remove “/bin” from PATH (which Manjaro adds by default) instead.

The question: do we really need the “/bin” symlink in “PATH” on Manjaro distribution?

In this case, the answer is quite simple:

If a single program is incorrectly dependent on a certain path, this is bad. However, this is by no means a reason to adjust the path of any distribution (especially since 99% of users do not use this program).

If it is not changed in the corresponding program (which would be logical), the user is left with only workarounds.

a) remove /bin from the path
b) arrange /bin in the path after /usr/bin
c) temporarily adjust the path when calling clang

In this respect, you have already found the right (& easy) solution to your problem :wink:
:footprints:
P.S.:
I think that this is not a problem with clang itself, but with the build scripts used. Because the build script decides which file should be recompiled (not the compiler)

There are also things like “ccache” that are intended to prevent the multiple build of an (unchanged) file.

Thanks for the reply!

this is by no means a reason to adjust the path of any distribution

OK!

remove /bin from the path

How to do it correctly for Manjaro? I can’t find it it any config file. The only way I found is to put “unset PATH” at the begin of “/etc/profile” file, but it looks like a workaround to me.

I think that this is not a problem with clang itself, but with the build scripts used. Because the build script decides which file should be recompiled (not the compiler)

That’s the problem I don’t know where to report the “real” bug. Looks like it works with correctly with GCC, but not with Clang (tried Clang+CMake+Make, Clang+CMake+Ninja, Clang+Meson+Ninja - all have the same issue).

There are also things like “ccache” that are intended to prevent the multiple build of an (unchanged) file.

Yes, but in this case it’s like a workaround (+ ccache never works to me with PCH enabled).

I found something in my home at: .zshrc

cat .zshrc |grep -E '\$PATH'
# If you come from bash you might have to change your $PATH.
export PATH=/usr/local/bin:$PATH
export PATH=$PATH:~/toolchains/gcc_4.8.4.201701_gnurx-elf/bin/

The first line inserts something to the start, the second does it to the end.
:footprints:

How could Path to /bin lead to different results than PATH to /usr/bin
when /bin is just a symlink to /usr/bin

there can be only one version of any software in /usr/bin - as /bin just links to that and is not a separate PATH but the same :man_shrugging:

1 Like

I don’t have zsh installed.

Now I noticed the problem comes from lightdm. When I use SDDM to launch Xfce4, there is no “/bin” in PATH :smile: Where lightdm is adding the “/bin” to the PATH?

there can be only one version of any software in /usr/bin - as /bin just links to that and is not a separate PATH but the same :man_shrugging:

Don’t understand either, that’s why created this thread :smile: Looks like clang (or build scripts when using clang) has a problem with this…


Also here is QtCreator issue.

echo $PATH in Xfce4:

/home/jo/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl



echo $PATH in Plasma (with SDDM instead of lightdm):

/home/jo/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl



In Xfce4, /bin is explicitly in the $PATH
In Plasma it is not.

These are two separate Virtual Machines - one Xfce4, one KDE Plasma.
The Xfce4 one has been used and modified the most - the Plasma is pretty much pristine.

They where not installed at the same time - the Plasma is much more recent, the Xfce4 is the oldest.

I don’t think it has got anything to do with the display manager used (lightdm vs. sddm)

Results on the same system:

  • I have “/bin” in PATH on Xfce4 when I start Xfce4 from lightdm
  • I have “/bin” in PATH on Plasma when I start Plasma from lightdm
  • I don’t have “/bin” in PATH on Xfce4 when I start Xfce4 from sddm
  • I don’t have “/bin” in PATH on Plasma when I start Plasma from sddm

Strange behavior…

Not the same - in my example, these where two totally different systems.
each one of them a separate VM

In yours you seem to change display managers and have two different desktops installed alongside each other.

/bin is still just a link to /usr/bin
there is nothing below /bin
everything is below /usr/bin

Finally found where the “/bin” is located. Lightdm has hardcoded “/bin” PATH here. I removed it, recompiled package, and the “/bin” is gone from my PATH…

… does it help your issue?

1 Like

Yes, all I wanted to know is where and why “/bin” is added to PATH. Now I know it’s not Manjaro issue, but lightdm issue.

Thanks for replies!

How so?

I think you are on a wrong track. :man_shrugging:

the actual users $PATH is defined differently - somewhere else

1 Like

I marked this answer as the solution to your question because it is by far the best answer you can get. LinkToAnswer

If you disagree with my choice, feel free to mark any other answer as the solution to your question, or remove the solution: You are in control! (If you disagree, just send me a private message explaining why I shouldn’t have done that, or a :heart: if you agree)

:innocent: P.S. In the future, please don’t forget to come back to your thread after solving your problem and mark the answer that helped you the most as the solution: Solution
Then the next person who has exactly the same problem as you can benefit from your contribution. Also, your thread will then be shown as “solved”.

I was looking for the PATH for a longer while in all possible scripts (/etc and $HOME) - I didn’t find anything which adds the “/bin” for bash shell.

But finally found it in lightdm code here. When I remove it from there - “/bin” is gone from PATH in Xfce4.

Removing “/bin” helps QtCreator to automatically (without manual modification of kits) find tools properly (on my PC). Now need to report issue somewhere to fix it for all users :smile: - clang or lightdm or both or maybe build systems…

:innocent: P.S. In the future, please don’t forget to come back to your thread after solving your problem and mark the answer that helped you the most as the solution:

Yes, will do!


Thanks again!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.