pytorch - 💡(How to fix) Fix Stable Linux binaries of LibTorch have broken soname and versioning in libgomp [3 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
pytorch/pytorch#177082Fetched 2026-04-08 00:22:19
View on GitHub
Comments
3
Participants
2
Timeline
23
Reactions
0
Participants
Timeline (top)
mentioned ×7subscribed ×7labeled ×6commented ×3

Fix Action

Fix / Workaround

Patchelf is capable of fixing the SONAME entry but not the .gnu.version_d section.

CPU: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 48 bits physical, 48 bits virtual Byte Order: Little Endian CPU(s): 16 On-line CPU(s) list: 0-15 Vendor ID: AuthenticAMD Model name: AMD Ryzen 7 7840U w/ Radeon 780M Graphics CPU family: 25 Model: 116 Thread(s) per core: 2 Core(s) per socket: 8 Socket(s): 1 Stepping: 1 Frequency boost: enabled CPU(s) scaling MHz: 47% CPU max MHz: 5134.8892 CPU min MHz: 419.1750 BogoMIPS: 6587.69 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good amd_lbr_v2 nopl xtopology nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpuid_fault cpb cat_l3 cdp_l3 hw_pstate ssbd mba perfmon_v2 ibrs ibpb stibp ibrs_enhanced vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local user_shstk avx512_bf16 clzero irperf xsaveerptr rdpru wbnoinvd cppc arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold vgif x2avic v_spec_ctrl vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid overflow_recov succor smca fsrm flush_l1d amd_lbr_pmc_freeze Virtualization: AMD-V L1d cache: 256 KiB (8 instances) L1i cache: 256 KiB (8 instances) L2 cache: 8 MiB (8 instances) L3 cache: 16 MiB (1 instance) NUMA node(s): 1 NUMA node0 CPU(s): 0-15 Vulnerability Gather data sampling: Not affected Vulnerability Ghostwrite: Not affected Vulnerability Indirect target selection: Not affected Vulnerability Itlb multihit: Not affected Vulnerability L1tf: Not affected Vulnerability Mds: Not affected Vulnerability Meltdown: Not affected Vulnerability Mmio stale data: Not affected Vulnerability Old microcode: Not affected Vulnerability Reg file data sampling: Not affected Vulnerability Retbleed: Not affected Vulnerability Spec rstack overflow: Mitigation; Safe RET Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Enhanced / Automatic IBRS; IBPB conditional; STIBP always-on; PBRSB-eIBRS Not affected; BHI Not affected Vulnerability Srbds: Not affected Vulnerability Tsa: Mitigation; Clear CPU buffers Vulnerability Tsx async abort: Not affected Vulnerability Vmscape: Mitigation; IBPB before exit to userspace

Code Example

$ readelf -dV libtorch/lib/libtorch_cpu.so | egrep '^[^ ]|libgomp'
Dynamic section at offset 0x156b1d28 contains 37 entries:
 0x0000000000000001 (NEEDED)             Shared library: [libgomp-98b21ff3.so.1]
Version symbols section '.gnu.version' contains 89326 entries:
Version definition section '.gnu.version_d' contains 1 entry:
Version needs section '.gnu.version_r' contains 9 entries:
  0x0250: Version: 1  File: libgomp-98b21ff3.so.1  Cnt: 3
$ readelf -dV libtorch/lib/libgomp-98b21ff3.so.1 | egrep '^[^ ]|libgomp'
Dynamic section at offset 0x45050 contains 31 entries:
 0x000000000000000e (SONAME)             Library soname: [libgomp.so.1]
Version symbols section '.gnu.version' contains 530 entries:
Version definition section '.gnu.version_d' contains 26 entries:
  000000: Rev: 1  Flags: BASE  Index: 1  Cnt: 1  Name: libgomp.so.1
Version needs section '.gnu.version_r' contains 3 entries:

---

Collecting environment information...
PyTorch version: N/A
Is debug build: N/A
CUDA used to build PyTorch: N/A
ROCM used to build PyTorch: N/A

OS: AlmaLinux 9.7 (Moss Jungle Cat) (x86_64)
GCC version: (GCC) 11.5.0 20240719 (Red Hat 11.5.0-11)
Clang version: 20.1.8 (AlmaLinux OS Foundation 20.1.8-3.el9)
CMake version: version 3.26.5
Libc version: glibc-2.34

Python version: 3.9.25 (main, Jan 14 2026, 00:00:00)  [GCC 11.5.0 20240719 (Red Hat 11.5.0-11)] (64-bit runtime)
Python platform: Linux-6.18.1-x86_64-with-glibc2.34
Is CUDA available: N/A
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect
Is XPU available: N/A
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: N/A
Caching allocator config: N/A

CPU:
Architecture:                            x86_64
CPU op-mode(s):                          32-bit, 64-bit
Address sizes:                           48 bits physical, 48 bits virtual
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               AuthenticAMD
Model name:                              AMD Ryzen 7 7840U w/ Radeon  780M Graphics
CPU family:                              25
Model:                                   116
Thread(s) per core:                      2
Core(s) per socket:                      8
Socket(s):                               1
Stepping:                                1
Frequency boost:                         enabled
CPU(s) scaling MHz:                      47%
CPU max MHz:                             5134.8892
CPU min MHz:                             419.1750
BogoMIPS:                                6587.69
Flags:                                   fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good amd_lbr_v2 nopl xtopology nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpuid_fault cpb cat_l3 cdp_l3 hw_pstate ssbd mba perfmon_v2 ibrs ibpb stibp ibrs_enhanced vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local user_shstk avx512_bf16 clzero irperf xsaveerptr rdpru wbnoinvd cppc arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold vgif x2avic v_spec_ctrl vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid overflow_recov succor smca fsrm flush_l1d amd_lbr_pmc_freeze
Virtualization:                          AMD-V
L1d cache:                               256 KiB (8 instances)
L1i cache:                               256 KiB (8 instances)
L2 cache:                                8 MiB (8 instances)
L3 cache:                                16 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Ghostwrite:                Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Old microcode:             Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Mitigation; Safe RET
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; Enhanced / Automatic IBRS; IBPB conditional; STIBP always-on; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Mitigation; Clear CPU buffers
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Mitigation; IBPB before exit to userspace

Versions of relevant libraries:
[pip3] Could not collect
[conda] Could not collect
RAW_BUFFERClick to expand / collapse

🐛 Describe the bug

Download an official stable Linux build of LibTorch from the website, say https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-2.10.0%2Bcpu.zip, and inspect the dynamic section and symbol versioning data:

$ readelf -dV libtorch/lib/libtorch_cpu.so | egrep '^[^ ]|libgomp'
Dynamic section at offset 0x156b1d28 contains 37 entries:
 0x0000000000000001 (NEEDED)             Shared library: [libgomp-98b21ff3.so.1]
Version symbols section '.gnu.version' contains 89326 entries:
Version definition section '.gnu.version_d' contains 1 entry:
Version needs section '.gnu.version_r' contains 9 entries:
  0x0250: Version: 1  File: libgomp-98b21ff3.so.1  Cnt: 3
$ readelf -dV libtorch/lib/libgomp-98b21ff3.so.1 | egrep '^[^ ]|libgomp'
Dynamic section at offset 0x45050 contains 31 entries:
 0x000000000000000e (SONAME)             Library soname: [libgomp.so.1]
Version symbols section '.gnu.version' contains 530 entries:
Version definition section '.gnu.version_d' contains 26 entries:
  000000: Rev: 1  Flags: BASE  Index: 1  Cnt: 1  Name: libgomp.so.1
Version needs section '.gnu.version_r' contains 3 entries:

In other words, libtorch_cpu.so believes it is linking against libgomp-HASH.so.1, whereas libgomp-HASH.so.1 believes itself to be a bare libgomp.so.1. These mismatches do not cause runtime problems—reasonably, for the NEEDED/SONAME one; who can even tell why, for the gnu.version_d/r one.

However, if you for example try to package these files into a Fedora or RHEL RPM, the (perhaps too-)smart build machinery gets very confused: the dependency generators cannot match the symbol versions (generating a Requires: mentioning libgomp-HASH.so.1 and a Provides: mentioning libgomp.so.1 that doesn’t satisfy it); while ldconfig, as invoked by the __brp_ldconfig macro, creates a symlink named libgomp.so.1 pointing to libgomp-HASH.so.1 (i.e. from the library’s embedded SONAME to the library itself), defeating the point of including the -HASH part in the first place.

Patchelf is capable of fixing the SONAME entry but not the .gnu.version_d section.

The process that builds LibTorch’s private libgomp should be modified to at least set the correct soname (this is the -h option of GNU ld or LLD). Whether this would also fix the symbol versioning I don’t know.

I’ll also note that the nightly builds such as https://download.pytorch.org/libtorch/nightly/cpu/libtorch-shared-with-deps-latest.zip include a bare libgomp.so.1 rather than a libgomp-HASH.so.1, so an alternative explanation would be that the hash wasn’t supposed to be included in the first place. That would be unfortunate, though, as it would make the distribution unsuitable for systemwide installation.

Versions

Collecting environment information...
PyTorch version: N/A
Is debug build: N/A
CUDA used to build PyTorch: N/A
ROCM used to build PyTorch: N/A

OS: AlmaLinux 9.7 (Moss Jungle Cat) (x86_64)
GCC version: (GCC) 11.5.0 20240719 (Red Hat 11.5.0-11)
Clang version: 20.1.8 (AlmaLinux OS Foundation 20.1.8-3.el9)
CMake version: version 3.26.5
Libc version: glibc-2.34

Python version: 3.9.25 (main, Jan 14 2026, 00:00:00)  [GCC 11.5.0 20240719 (Red Hat 11.5.0-11)] (64-bit runtime)
Python platform: Linux-6.18.1-x86_64-with-glibc2.34
Is CUDA available: N/A
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect
Is XPU available: N/A
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: N/A
Caching allocator config: N/A

CPU:
Architecture:                            x86_64
CPU op-mode(s):                          32-bit, 64-bit
Address sizes:                           48 bits physical, 48 bits virtual
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               AuthenticAMD
Model name:                              AMD Ryzen 7 7840U w/ Radeon  780M Graphics
CPU family:                              25
Model:                                   116
Thread(s) per core:                      2
Core(s) per socket:                      8
Socket(s):                               1
Stepping:                                1
Frequency boost:                         enabled
CPU(s) scaling MHz:                      47%
CPU max MHz:                             5134.8892
CPU min MHz:                             419.1750
BogoMIPS:                                6587.69
Flags:                                   fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good amd_lbr_v2 nopl xtopology nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpuid_fault cpb cat_l3 cdp_l3 hw_pstate ssbd mba perfmon_v2 ibrs ibpb stibp ibrs_enhanced vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local user_shstk avx512_bf16 clzero irperf xsaveerptr rdpru wbnoinvd cppc arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold vgif x2avic v_spec_ctrl vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid overflow_recov succor smca fsrm flush_l1d amd_lbr_pmc_freeze
Virtualization:                          AMD-V
L1d cache:                               256 KiB (8 instances)
L1i cache:                               256 KiB (8 instances)
L2 cache:                                8 MiB (8 instances)
L3 cache:                                16 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Ghostwrite:                Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Old microcode:             Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Mitigation; Safe RET
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; Enhanced / Automatic IBRS; IBPB conditional; STIBP always-on; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Mitigation; Clear CPU buffers
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Mitigation; IBPB before exit to userspace

Versions of relevant libraries:
[pip3] Could not collect
[conda] Could not collect

(I don’t have PyTorch nor LibTorch installed on the machine that builds the RPM, so this doesn’t seem all that useful)

cc @seemethere @malfet @atalman @tinglvv @nWEIdia

extent analysis

Fix Plan

Modify the build process to set the correct soname

To fix the issue, we need to modify the build process to set the correct soname for the libgomp library. We can do this by adding the -h option to the GNU ld or LLD linker.

Using GNU ld

ld -h libgomp.so.1 -o libgomp.so.1

Using LLD

lld -h libgomp.so.1 -o libgomp.so.1

Update the build script

We need to update the build script to include the above command. For example, if we are using a Makefile, we can add the following line to the build target:

build: libgomp.so.1
    ld -h libgomp.so.1 -o libgomp.so.1

Verify the fix

To verify the fix, we can run the following command:

readelf -dV libtorch/lib/libtorch_cpu.so | egrep '^[^ ]|libgomp'

This should show the correct soname for the libgomp library.

Extra Tips

  • Make sure to update the build script to include the correct soname for the libgomp library.
  • Verify the fix by running the readelf command.
  • If you are using a RPM build process, make sure to update the RPM spec file to include the correct soname for the libgomp library.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING