Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 648736 - sci-physics/geant[threads] uses tls-model=initial-exec, preventing dynamic loading
Summary: sci-physics/geant[threads] uses tls-model=initial-exec, preventing dynamic lo...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Guilherme Amadio
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-24 23:14 UTC by Oliver Freyermuth
Modified: 2018-05-21 13:55 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Freyermuth 2018-02-24 23:14:55 UTC
Geant4 by default uses:
-ftls-model=initial-exec -pthread
if compiled with "threads". 

This prevents anything else on the system from dynamically loading the installed libraries, since, as the gcc manpage states:
"The default without -fpic is initial-exec; with -fpic the default is global-dynamic."

An example for such failure is https://github.com/gentoo/gentoo/pull/7088 . Simple reproducer, if ROOT is installed:

root [1] gSystem->Load("/usr/lib64/libG4particles.so")
cling::DynamicLibraryManager::loadLibrary(): /usr/lib64/libG4particles.so: cannot allocate memory in static TLS block
(int) -1

Geant allows to select TLS model:
https://its.cern.ch/jira/browse/GEANT-94

I am unsure whether this should be changed to global-dynamic by default, at least for 17.0 profiles. 
The gain would be that e.g. sci-physics/geant-vmc can be compiled even against sci-physics/geant[threads].
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-02-26 11:10:01 UTC
Just to be clear, the best solution here would be to remove -ftls-model parameter altogether and let compiler use its default.
Comment 2 Larry the Git Cow gentoo-dev 2018-05-18 15:38:53 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=395a5469e0d79b72275ebb16275b1957dc65a7f4

commit 395a5469e0d79b72275ebb16275b1957dc65a7f4
Author:     Guilherme Amadio <amadio@gentoo.org>
AuthorDate: 2018-05-18 15:13:55 +0000
Commit:     Guilherme Amadio <amadio@gentoo.org>
CommitDate: 2018-05-18 15:35:26 +0000

    sci-physics/geant: choose right tls model with USE=threads
    
    Closes: https://bugs.gentoo.org/648736
    
    Package-Manager: Portage-2.3.38, Repoman-2.3.9

 sci-physics/geant/geant-4.10.03-r1.ebuild | 1 +
 1 file changed, 1 insertion(+)
Comment 3 Guilherme Amadio gentoo-dev 2018-05-18 15:44:27 UTC
I am using Geant4's own option for now, but asked upstream to provide a way to not add any -ftls-model option to the compilation flags in a later version. If this is not enough I will patch out the option by force, as suggested by mgorny.
Comment 4 Oliver Freyermuth 2018-05-19 00:30:31 UTC
(In reply to Guilherme Amadio from comment #3)
> I am using Geant4's own option for now, but asked upstream to provide a way
> to not add any -ftls-model option to the compilation flags in a later
> version. If this is not enough I will patch out the option by force, as
> suggested by mgorny.

Thanks! I'll test =sci-physics/geant-4.10.03-r1[threads] against sci-physics/geant-vmc this weekend and provide feedback at the corresponding Github issue. 

However, does this not warrant a revbump? 
Otherwise, sci-physics/geant-vmc will still be broken for users with existing installations of =sci-physics/geant-4.10.03-r1[threads] unless they recompile explicitly. 
In any case, it's probably best to wait with a revbump until I have tested to confirm it actually works (even though I'm sure it will).
Comment 5 Guilherme Amadio gentoo-dev 2018-05-21 10:38:49 UTC
(In reply to Oliver Freyermuth from comment #4)
> (In reply to Guilherme Amadio from comment #3)
> > I am using Geant4's own option for now, but asked upstream to provide a way
> > to not add any -ftls-model option to the compilation flags in a later
> > version. If this is not enough I will patch out the option by force, as
> > suggested by mgorny.
> 
> Thanks! I'll test =sci-physics/geant-4.10.03-r1[threads] against
> sci-physics/geant-vmc this weekend and provide feedback at the corresponding
> Github issue. 
> 
> However, does this not warrant a revbump? 

Yes, it makes sense. I want to bump version to 10.4, and don't want everyone to rebuild twice. I already bumped clhep, let me finish bumping Geant4, then we can merge the PR.
Comment 6 Oliver Freyermuth 2018-05-21 13:55:30 UTC
Ok, understood! 
In any case, most people will already have rebuilt current Geant as a consequence of the clhep bump.