On 6/29/26 13:46, IOhannes m zmoelnig via Pd-dev wrote:
and on macOS:
 > ld: illegal thread local variable reference to regular symbol _pd_this


i haven't checked what the problem is on macOS, but the root cause (according to [34212217]) appears to be similar to what christof fixed for windows in [c3497b77].

ah, on macOS the issue appears to be, that Pd (and externals) are typically built with "-mmacosx-version-min=10.6" which does *not* support exporting TLS-vars. but libpd (which is typically built with PDINSTANCE enabled and apparently works fine on macOS) is built with "-mmacosx-version-min=10.9" which does support exporting TLS-vars.

in any case: since we do need to work around the TLS-var issue on Windows anyhow, can't we just do the same on all platforms?

i would like to suggest to:
- remove 'pd_this' (as a public variable declaration) from m_pd.h
- have a 'pd_this' macro pointing to pd_getinstance()
  - the keeps API-compatibility
- we already have this macro for PDINSTANCE-on-Windows, and another one for non-PDINSTANCE)
- *maybe* export the 'pd_this' variable, for ABI compatibility.
- make the pd_getinstance() function available for both w/o PDINSTANCE


i'm not really sure whether the ABI compatibility is actually required.
my understanding is, that PDINSTANCE is mainly used with libpd, and the use case is to either link externals statically or build them alongside libpd. that is: the expectation is not, that one would be able to load externals without having them compiled explicitly (so API compat should be enough). but as said previously: this is not my turf and I might be completely mistaken, and actual users of libpd might have a different (and more informed) view.


my understanding of "pd_this" in the public headers is, that it's only need to provide a way to allow externals to use the symbol shortcut variables (e.g. "&s_float"). since the current implementation only keeps API compatibility, but not ABI compat, shouldn't we just *deprecate* the use of these static symbols and suggest to use 'gensym()' instead? (most code i've seen does not use them in performance-critical code; and for those few cases wehere they *are* using in performance-critical code, it's easy enough to just provide your own per-instance pointer)


while we are at it:
i also notice that there are two public variables (in m_pd.h):
`pd_instances` and `pd_ninstances`.

what is their use? i haven't seen any case (outside Pd itself) that makes use them. can they be removed (or replaced by a getter function, like libpd_num_instances()?)


dasmsdrf
IOhannes



--
please do not CC me for list-emails

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

 ---
[email protected] - the Pd developers' mailinglist
https://lists.iem.at/hyperkitty/list/[email protected]/message/WXLAA4A3IJZEP4FIOFJG5ED2Q64AVEXO/

Reply via email to