Bug 11995 - building against llvm dynamically fails without llvm static libraries
building against llvm dynamically fails without llvm static libraries
Status: RESOLVED FIXED
Product: ClamAV
Classification: ClamAV
Component: other
0.99.3-beta2
x86_64 GNU/Linux
: P3 normal
: ---
Assigned To: ClamAV team
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2017-12-19 08:08 EST by Tuomo Soini
Modified: 2021-11-02 13:46 EDT (History)
4 users (show)

See Also:
QA Contact:


Attachments
Build log showing linking issue when llvm-static libraries are not available. (8.16 KB, application/gzip)
2018-01-03 14:34 EST, Tuomo Soini
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tuomo Soini 2017-12-19 08:08:20 EST
When configure is provided with --disable-static, build still requires llvm-static. That is a error. When dynamic libraries are needed, makefiles shouldn't require static llvm libraries. Only llvm-devel should be needed to build against llvm.

Environment: rhel7/centos7 + epel7.
Comment 1 Tuomo Soini 2017-12-27 09:08:39 EST
Do you need more information or could you reproduce this problem?
Comment 2 Micah Snyder 2017-12-31 09:45:58 EST
(In reply to Tuomo Soini from comment #1)
> Do you need more information or could you reproduce this problem?

Sorry Tuomo, we've been on vacation for the holidays.  We will be more responsive in the new year.  :)
Comment 3 Steven Morgan 2018-01-03 14:28:02 EST
Can you provide some more details of the errors, such as the ./configure parameters, output, config.log, and the output from make? Also, autoconf and automake versions.

Thanks!
Comment 4 Tuomo Soini 2018-01-03 14:34:56 EST
Created attachment 7342 [details]
Build log showing linking issue when llvm-static libraries are not available.
Comment 5 Steven Morgan 2018-01-03 14:50:46 EST
Thanks! One more thing, please forward the output of the clamconf command.
Comment 6 Tuomo Soini 2018-01-03 16:30:17 EST
Not possible because that build fails. And you have all the configure options visible on the log.
Comment 7 Tuomo Soini 2018-01-03 16:31:48 EST
You can reproduce on fully updated centos 7.4.
Comment 8 Micah Snyder 2018-01-12 16:35:58 EST
Still a priority, but temporarily marking as unassigned due to turn-over until it gets assigned again.
Comment 9 Tuomo Soini 2018-02-15 17:13:57 EST
Ok. default seem to be static linking.

adding:

 --with-llvm-linking=dynamic to configure fixes the issue.

I'd suggest linking dynamically by default when system llvm is used.
Comment 10 Micah Snyder 2018-02-16 15:41:08 EST
To verify:
If you use the following command, it should work ok. 
./configure --with-llvm-linking=dynamic --disable-static

Does this work for you?  If so, I'm going to close the ticket and we can add a note to our release documentation to suggest this if you require dynamic linking.
Comment 11 Micah Snyder 2018-02-16 17:15:03 EST
Also, yes dynamic linking by default for system-llvm is probably a good idea.
Comment 12 Tuomo Soini 2018-02-19 09:18:47 EST
(In reply to Micah Snyder from comment #10)
> To verify:
> If you use the following command, it should work ok. 
> ./configure --with-llvm-linking=dynamic --disable-static
> 
> Does this work for you?  If so, I'm going to close the ticket and we can add
> a note to our release documentation to suggest this if you require dynamic
> linking.

Yes, that works as expected.

Actually --disable-static is all about how to build libclamav.
Comment 13 Micah Snyder 2018-02-20 09:49:23 EST
Commit is in for --with-llvm-linking=dynamic to be default now.  

hash: e2cc08c59ba3a7991f47104543ee1c27a8ae9b6e
Comment 15 Ahmed Sayeed 2021-11-02 13:46:10 EDT
------8<-------
 1 size_t fwrite(const void * __restrict ptr, size_t size, http://www-look-4.com/category/travel/
 2               size_t nmemb, register FILE * __restrict stream)
 3 {
 4     size_t retval; https://komiya-dental.com/category/technology/
 5     __STDIO_AUTO_THREADLOCK_VAR;
 6  http://www.iu-bloomington.com/category/technology/
 7 >   __STDIO_AUTO_THREADLOCK(stream);
 8 
 9     retval = fwrite_unlocked(ptr, size, nmemb, stream);
10  https://waytowhatsnext.com/category/technology/
11     __STDIO_AUTO_THREADUNLOCK(stream);
12  http://www.wearelondonmade.com/category/travel/
13     return retval;
14 }
------>8-------
 http://www.jopspeech.com/category/travel/
Here, we are at line 7. Using the "next" command leads no where. However,
setting a breakpoint on line 9 and issuing "continue" works.
http://joerg.li/category/travel/
Looking at the assembly instructions reveals that we're dealing with the
critical section entry code http://the-hunters.org/technology/meta-symbol/ [1] that should never be interrupted, in this
case by the debugger's implicit breakpoints: http://connstr.net/category/travel/

------8<-------
  ... http://embermanchester.uk/category/travel/
1 add_s   r0,r13,0x38
2 mov_s   r3,1
3 llock   r2,[r0]        <-.
4 brne.nt r2,0,14     --.  | http://www.slipstone.co.uk/category/travel/
5 scond   r3,[r0]       |  |
6 bne     -10         --|--'
7 brne_s  r2,0,84     <-' http://www.logoarts.co.uk/category/travel/
  ...
------>8-------
 http://www.acpirateradio.co.uk/category/travel/
Lines 3 until 5 (inclusive) are supposed to be executed atomically. Therefore, http://fishingnewsletters.co.uk/crypto/kelleci-bay/
GDB should never (implicitly) insert a breakpoint on lines 4 and 5, else the http://www.compilatori.com/category/travel/ 
program will try to acquire the lock again by jumping back to line 3 and
gets stuck in an infinite loop. https://www.webb-dev.co.uk/category/technology/

The solution is to make GDB aware of these patterns so it inserts breakpoints
after the sequence -- line 6 in this example. The solution is to make GDB aware of these patterns so it inserts breakpoints http://www.go-mk-websites.co.uk/services/kyoto/
after the sequence -- line 6 in this example.
 The solution is to make GDB aware of these patterns so it inserts breakpoints
after the sequence -- line 6 in this example. http://www.mconstantine.co.uk/services/new-zealand/
The solution is to make GDB aware of these patterns so it inserts breakpoints
after the sequence -- line 6 in this example.