<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><font size="+1">After doing lots of experiments, ranging from
installing clang-6 from its official build (<a class="moz-txt-link-freetext" href="http://apt.llvm.org/xenial">http://apt.llvm.org/xenial</a>)
to checking Cmake failure logs and tweaking its settings, I've
finally happened to find out what was wrong.</font></p>
<p><font size="+1">I used </font><font size="+1"><tt><br>
</tt></font></p>
<p><font size="+1"><tt>-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang </tt></font><font size="+1"><br>
</font></p>
<p><font size="+1">when I ran CMake because I saw clang and clang++
are symlinks to bin/clang-x. This caused the Cmake failure, and
it was gone when I happened to use: <br>
</font></p>
<p><font size="+1"><font size="+1"><tt>-DCMAKE_CXX_COMPILER=clang++-x</tt></font></font></p>
<font size="+1">My guess is that the clang code must check which
original command was used to invoke it. When it's invoked through
the clang symlink, it acts like the C compiler; when through the
clang++ symlink, like the C++ compiler.<br>
<br>
Thank all of you who helped. Now with clang++-6.0 and lld-6.0, I
can build clang in 9s after changing a checker. Yeh! The entire
cmake command line looks like this:<br>
<br>
</font><font size="+1"><tt>cmake -G "Unix Makefiles"
-DLLVM_OPTIMIZED_TABLEGEN=true -DCMAKE_BUILD_TYPE=Debug
-DBUILD_SHARED_LIBS=ON ../llvm/ -DLLVM_USE_LINKER=lld-6.0
-DCMAKE_C_COMPILER=clang-6.0 -DCMAKE_CXX_COMPILER=clang++-6.0</tt></font><font
size="+1"><br>
</font><br>
<pre class="moz-signature" cols="72">Thanks,
Lou
</pre>
<div class="moz-cite-prefix">On 09/19/2018 02:58 PM, Kristóf Umann
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAGcXOD7vhXKrFkhrQqfk9=DDVaO4VDcKoQR23JSW043uzJ=ggg@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<div dir="auto">
<div>Uhh. I never encountered that error, so I can't offer
anything that google can not :(
<div dir="auto"><br>
</div>
<div dir="auto">All the other tips however others and I gave
should speed up compilation and linking, so gcc is fine if
you are having a lot of trouble building with clang,
especially if linking is the most ime consuming part. Though
it would be beneficial to get to the bottom of this if you
have the time.</div>
<div dir="auto"><br>
</div>
One more thing, building shared libraries will make linking a
whole lot faster (the resulting binary will be slower, but
that won't hurt much in a debug build anyway) <span
style="color:inherit;font-family:menlo,"liberation
mono",consolas,"dejavu sans
mono","ubuntu mono","courier
new","andale mono","lucida
console",monospace;font-size:inherit">-DBUILD_SHARED_LIBS</span><span
style="color:inherit;font-family:menlo,"liberation
mono",consolas,"dejavu sans
mono","ubuntu mono","courier
new","andale mono","lucida
console",monospace;font-size:inherit;font-weight:bold">=</span><span
style="color:inherit;font-family:menlo,"liberation
mono",consolas,"dejavu sans
mono","ubuntu mono","courier
new","andale mono","lucida
console",monospace;font-size:inherit">ON.</span>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 19 Sep 2018 23:44, "Lou Wynn"
<<a href="mailto:lewisurn@gmail.com" target="_blank"
moz-do-not-send="true">lewisurn@gmail.com</a>> wrote:<br
type="attribution">
<blockquote class="m_5195514035617194595quote"
style="margin:0 0 0 .8ex;border-left:1px #ccc
solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<p><tt><font size="+1">~/work/git-repos/llvm/release-<wbr>git$
which clang<br>
/usr/bin/clang<br>
</font></tt></p>
<p><tt><font size="+1">~/work/git-repos/llvm/release-<wbr>git$
clang -###<br>
clang version 3.8.0-2ubuntu4
(tags/RELEASE_380/final)<br>
Target: x86_64-pc-linux-gnu<br>
Thread model: posix<br>
InstalledDir: /usr/bin</font></tt></p>
<p><tt><font size="+1"><br>
</font></tt></p>
<p><tt><font size="+1">I also tried with a self-built
clang, and got the same error.</font></tt></p>
<p><br>
</p>
<pre class="m_5195514035617194595m_5815235433951038264moz-signature" cols="72">Thanks,
Lou
</pre>
<div class="m_5195514035617194595elided-text">
<div
class="m_5195514035617194595m_5815235433951038264moz-cite-prefix"><br>
On 09/19/2018 02:41 PM, Kristóf Umann wrote:<br>
</div>
<blockquote type="cite">
<div dir="auto">Are you using a prebuild binary?
Are you sure you're using the clang you'd like
to compile with? (`which clang`?)</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 19 Sep 2018 23:38,
"Lou Wynn" <<a
href="mailto:lewisurn@gmail.com"
target="_blank" moz-do-not-send="true">lewisurn@gmail.com</a>>
wrote:<br type="attribution">
<blockquote class="gmail_quote"
style="margin:0 0 0 .8ex;border-left:1px
#ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<p><font size="+1">When I use clang to
compile (gcc is fine), I got cmake
error:<br>
</font></p>
<p><tt><font size="+1">-- Performing Test
HAVE_CXX_ATOMICS_WITHOUT_LIB<br>
-- Performing Test
HAVE_CXX_ATOMICS_WITHOUT_LIB -
Failed<br>
-- Looking for __atomic_fetch_add_4
in atomic<br>
-- Looking for __atomic_fetch_add_4
in atomic - found<br>
-- Performing Test
HAVE_CXX_ATOMICS_WITH_LIB<br>
-- Performing Test
HAVE_CXX_ATOMICS_WITH_LIB - Failed<br>
CMake Error at
cmake/modules/CheckAtomic.cmak<wbr>e:50
(message):<br>
Host compiler must support
std::atomic!<br>
Call Stack (most recent call first):<br>
cmake/config-ix.cmake:323
(include)<br>
CMakeLists.txt:577 (include)</font></tt></p>
<p><tt><font size="+1"><br>
</font></tt></p>
<p><font size="+1">How can I fix it? </font><font
size="+1"><font size="+1">I checkout
source code from the git mirror. I'm
running ubuntu 16.04.1 LTS.<br>
</font></font></p>
<p><br>
</p>
<pre class="m_5195514035617194595m_5815235433951038264m_8167128743136673462moz-signature" cols="72">Thanks,
Lou
</pre>
<div
class="m_5195514035617194595m_5815235433951038264m_8167128743136673462moz-cite-prefix">On
09/19/2018 12:02 AM, Kristóf Umann
wrote:<br>
</div>
<blockquote type="cite">
<div dir="auto">Hi!
<div dir="auto"><br>
</div>
<div dir="auto">A couple tips I can
give:</div>
<div dir="auto"> * Compile with
clang. Make sure you use a release
build for this purpose, optimized
with LTO. I usually just download a
prebuild binary and go with that.
Clang tends to be about 2-3 times
faster than gcc.</div>
<div dir="auto"> * For linking, use
LLD, a linker part of the LLVM
family. Especially with -j8, it will
make a significant difference. Your
next best option is gnu gold.</div>
<div dir="auto"><br>
</div>
<div dir="auto">Great to hear about a
new checker! I'd encourage you to
upload your work in progress early
on to phabricator, even if it only
contains an empty callback, because
an entire working solution (if
lengthy enough) can drastically
increase the time it takes to review
it.</div>
<div dir="auto"><br>
</div>
<div dir="auto">I know because I made
that mistake :).</div>
<div dir="auto"><br>
</div>
<div dir="auto">Cheers,</div>
<div dir="auto">Kristóf Umann</div>
<br>
<div class="gmail_extra" dir="auto"><br>
<div class="gmail_quote">On 19 Sep
2018 04:06, "Lou Wynn via cfe-dev"
<<a
href="mailto:cfe-dev@lists.llvm.org"
target="_blank"
moz-do-not-send="true">cfe-dev@lists.llvm.org</a>>
wrote:<br type="attribution">
<blockquote
class="m_5195514035617194595m_5815235433951038264m_8167128743136673462quote"
style="margin:0 0 0
.8ex;border-left:1px #ccc
solid;padding-left:1ex">
<div text="#000000"
bgcolor="#FFFFFF">
<p>I do need debug information
because tracing code is a
great way for me to get
familiarized with clang and
the static analyzer.</p>
<p>I've managed to run "make
-j8 clang" at the top of the
build directory. However,
the final linking process
takes too long now. Is there
a way to build a thin
version that only runs the
static analyzer? I think
that I can at least cut the
code gen part out of the
build process but have no
idea how. The only command I
run is "clang -cc1 -analyze
-analyzer-checker=xxx" It'd
be great if I could reduce
the final object file to few
hundred megabytes.<br>
</p>
<p><tt>[ 96%] Built target
clangStaticAnalyzerCore</tt></p>
<div
class="m_5195514035617194595m_5815235433951038264m_8167128743136673462quoted-text"><tt><br>
</tt><tt>Scanning
dependencies of target
clangStaticAnalyzerCheckers</tt><tt><br>
</tt></div>
<tt>[ 96%] Building CXX object
tools/clang/lib/StaticAnalyzer<wbr>/Checkers/CMakeFiles/clangStat<wbr>icAnalyzerCheckers.dir/Integer<wbr>OverflowChecker.cpp.o</tt><tt><br>
</tt><tt>[ 96%] Linking CXX
static library
../../../../../lib/libclangSta<wbr>ticAnalyzerCheckers.a</tt><tt><br>
</tt><tt>[100%] Built target
clangStaticAnalyzerCheckers</tt><tt><br>
</tt><tt>[100%] Linking CXX
executable
../../../../bin/clang
<-- this take most time
now</tt><tt><br>
</tt><tt>[100%] Built target
clang</tt><tt><br>
</tt><tt><br>
</tt><tt>real 2m22.707s</tt><tt><br>
</tt><tt>user 2m10.812s</tt><tt><br>
</tt><tt>sys 0m14.936s</tt><tt><br>
</tt><br>
<pre class="m_5195514035617194595m_5815235433951038264m_8167128743136673462m_-5433425466101596033moz-signature" cols="72">Thanks,
Lou
</pre>
<div
class="m_5195514035617194595m_5815235433951038264m_8167128743136673462elided-text">
<div
class="m_5195514035617194595m_5815235433951038264m_8167128743136673462m_-5433425466101596033moz-cite-prefix">On
09/18/2018 06:25 PM, Reid
Kleckner wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">If the
clang binary is 2GB, I
would recommend building
in Release mode with
assertions enabled.
Linking binaries without
debug information is
dramatically faster.
This means passing
-DCMAKE_BUILD_TYPE=Release
-DLLVM_ENABLE_ASSERTIONS=ON to cmake.
<div><br>
If you use debug
information, I
recommend explicitly
building one target,
the target you are
testing (usually
clang), until you feel
the need to run the
complete clang test
suite.</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr">On Tue,
Sep 18, 2018 at 5:42
PM Lou Wynn via
cfe-dev <<a
href="mailto:cfe-dev@lists.llvm.org"
target="_blank"
moz-do-not-send="true">cfe-dev@lists.llvm.org</a>>
wrote:<br>
</div>
<blockquote
class="gmail_quote"
style="margin:0 0 0
.8ex;border-left:1px
#ccc
solid;padding-left:1ex">Hi,<br>
<br>
I'm writing my first
clang static analyzer
checker. I wrote the
scaffold<br>
code to add the
checker into clang.
But every time when I
change the<br>
checker implementation
code, the build
process after
generating the<br>
checker object file is
very slow. It's over 4
minutes in my laptop,<br>
which has the
i7-6820HQ four core
CPU and 32G memory.
The generated<br>
clang binary is over
2G. The affected
artifacts are as
follows:<br>
<br>
---------------------<br>
<br>
Scanning dependencies
of target
clangStaticAnalyzerCheckers<br>
[ 95%] Building CXX
object<br>
tools/clang/lib/StaticAnalyzer<wbr>/Checkers/CMakeFiles/clangStat<wbr>icAnalyzerCheckers.dir/Integer<wbr>OverflowChecker.cpp.o<br>
[ 95%] Linking CXX
static library<br>
../../../../../lib/libclangSta<wbr>ticAnalyzerCheckers.a<br>
[ 98%] Built target
clangStaticAnalyzerCheckers<br>
[ 98%] Linking CXX
executable
../../../../bin/arcmt-test<br>
[ 98%] Linking CXX
executable
../../../../bin/clang-check<br>
[ 98%] Linking CXX
executable
../../../../bin/clang<br>
[ 98%] Linking CXX
shared library
../../../../lib/libclang.so<br>
[ 98%] Built target
arcmt-test <---
this seems to take the
most time<br>
[ 98%] Built target
libclang<br>
[ 98%] Linking CXX
executable
../../../../bin/c-arcmt-test<br>
[ 98%] Linking CXX
executable
../../../../bin/c-index-test<br>
[ 98%] Built target
c-arcmt-test<br>
[ 98%] Built target
clang-check<br>
[ 98%] Built target
clang<br>
[100%] Built target
c-index-test<br>
<br>
real 4m23.014s<br>
user 8m4.032s<br>
sys 0m51.992s<br>
<br>
---------------------<br>
<br>
How can I speed up the
build process so that
I don't have to wait
for<br>
almost 4.5 minute for
a single change in the
implementation code? I
only<br>
work on the checker of
the static analyzer.<br>
<br>
-- <br>
Thanks,<br>
Lou<br>
<br>
______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a
href="mailto:cfe-dev@lists.llvm.org"
target="_blank"
moz-do-not-send="true">cfe-dev@lists.llvm.org</a><br>
<a
href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev"
rel="noreferrer"
target="_blank"
moz-do-not-send="true">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
</blockquote>
</div>
</blockquote>
<br>
</div>
</div>
<br>
______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a
href="mailto:cfe-dev@lists.llvm.org"
target="_blank"
moz-do-not-send="true">cfe-dev@lists.llvm.org</a><br>
<a
href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev"
rel="noreferrer"
target="_blank"
moz-do-not-send="true">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</blockquote>
<br>
</div>
</blockquote>
</div>
</div>
</blockquote>
<br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</blockquote>
<br>
</body>
</html>