[J3] [EXTERNAL] [BULK] Re: Compiler internal type tables and shared vs static libraries

Clune, Thomas L. (GSFC-6101) thomas.l.clune at nasa.gov
Mon May 13 15:39:10 UTC 2024


Hi Steve,

Thank you for the response – you said it well, and was more-or-less what I was suspecting, except for that last sentence.

In the situation you describe, the only way I can imagine for U to be able to call back to M is if U passes a procedure pointer to M. Is that what happens?

No – definitely not passing as a procedure pointer.    Library U actually  has USE statements that access M and when U is built we include libM.a in the command line args to the compiler.   (All done through CMake so the actual command is quite large and probably not worth pasting here.)

The surprising thing is that this seems to work “most of the time”.  Indeed, until quite recently.   The actual software stack is much more complex than I have implied in this thread, so something else unrelated must have recently changed that changes the odds of the mismatch you have described.

Thanks again,


  *   Tom


From: J3 <j3-bounces at mailman.j3-fortran.org> on behalf of Steve Lionel via J3 <j3 at mailman.j3-fortran.org>
Date: Monday, May 13, 2024 at 10:57 AM
To: General J3 interest list <j3 at mailman.j3-fortran.org>
Cc: Steve Lionel <steve at stevelionel.com>
Subject: [EXTERNAL] [BULK] Re: [J3] Compiler internal type tables and shared vs static libraries
CAUTION: This email originated from outside of NASA.  Please take care when clicking links or opening attachments.  Use the "Report Message" button to report suspicious messages to the NASA SOC.


Both of these things cannot be true:

> However, U is not linked to M
>  (U is linked to M.)

When U is built, it links to the compiler's support library. The executable application that links to M (you didn't discuss that, but there needs to be one) also links to the compiler's support library. If both are linked to the shared (.so) library, everything is good. But if one or both is linked to the static version of the library, you then have two copies of the support library that don't know about each other. This can cause strange issues when there's some run-time context that is expected to be shared.

It's possible that there is some indirect table reference that is going awry - a lot would depend on which compiler you are using. I wouldn't really expect a "sometimes" problem here, but it's the best I can think of (and I've encountered this in user applications many times over the years.)

In the situation you describe, the only way I can imagine for U to be able to call back to M is if U passes a procedure pointer to M. Is that what happens?

Steve


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20240513/5e763f19/attachment.htm>


More information about the J3 mailing list