<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Binary size higher with statically-linked libomp.a"
href="https://bugs.llvm.org/show_bug.cgi?id=43419">43419</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Binary size higher with statically-linked libomp.a
</td>
</tr>
<tr>
<th>Product</th>
<td>OpenMP
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Runtime Library
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>pirama@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>danalbert@google.com, llvm-bugs@lists.llvm.org, srhines@google.com
</td>
</tr></table>
<p>
<div>
<pre>This was originally reported a while ago in the Android NDK bug tracker as
<a href="https://github.com/android/ndk/issues/742">https://github.com/android/ndk/issues/742</a>.
Statically-linking libomp.a for a simple OpenMP hello world program,
<a href="https://computing.llnl.gov/tutorials/openMP/samples/C/omp_hello.c">https://computing.llnl.gov/tutorials/openMP/samples/C/omp_hello.c</a>, produces a
468K binary (after strip). gcc + libgomp.a, in comparison, produces a binary
of size 128K.
I want a sanity check if this is expected behavior or if the runtime can be
better organized for static linking.
Steps to reproduce:
Build OpenMP statically with:
-DLIBOMP_ENABLE_SHARED=OFF
-DCMAKE_BUILD_TYPE=Release
$ release/bin/clang++ -fopenmp=libomp omp_hello.cpp -ldl -fuse-ld=lld
-static-openmp
$ du -sh a.out
548K
$ strip a.out && du -sh a.out
468K
* gold produces a 464K binary.
* Adding -fvisibility=hidden -ffunction-sections -fdata-sections to C, CXX
flags, and -Wl,--gc-sections,
the unstripped binary is 2.2M but the stripped binary is 344K.
* Bloaty [<a href="https://github.com/google/bloaty">https://github.com/google/bloaty</a>]:
$ bloaty a.out -d fullsymbols produces the following:
75.9% 414Ki 71.2% 338Ki [1339 Others]
5.5% 30.3Ki 6.4% 30.3Ki [section .rodata]
2.8% 15.1Ki 3.2% 15.0Ki __kmp_aux_affinity_initialize()
1.9% 10.6Ki 2.2% 10.6Ki __kmp_stg_parse_affinity(char const*, char
const*, void*)
0.0% 39 2.0% 9.65Ki __kmp_sighldrs
1.5% 8.35Ki 1.8% 8.35Ki [section .text]
1.5% 8.03Ki 1.7% 7.99Ki __kmp_fork_call
1.4% 7.89Ki 1.6% 7.78Ki
__kmp_affinity_create_cpuinfo_map(AddrUnsPair**, int*, kmp_i18n_id*, _IO_FILE*)
1.4% 7.68Ki 1.6% 7.58Ki
__kmp_affinity_create_x2apicid_map(AddrUnsPair**, kmp_i18n_id*)
0.9% 5.18Ki 1.1% 5.12Ki __kmp_stg_parse_omp_schedule(char const*,
char const*, void*)
0.9% 4.97Ki 1.0% 4.93Ki __kmp_allocate_team
0.8% 4.52Ki 0.9% 4.43Ki
__kmp_affinity_create_apicid_map(AddrUnsPair**, kmp_i18n_id*)
0.8% 4.36Ki 0.0% 0 [Unmapped]
0.0% 52 0.8% 4.00Ki __kmp_threadprivate_d_table
0.7% 3.98Ki 0.8% 3.82Ki void __kmp_dispatch_init_algorithm<long
long>(ident*, int, dispatch_private_info_template<long long>*, sched_type, long
long, long long, traits_t<long long>::signed_t, traits_t<long long>::signed_t,
long long, long long)
0.7% 3.96Ki 0.8% 3.92Ki __kmp_balanced_affinity
0.7% 3.77Ki 0.8% 3.71Ki __kmp_stg_parse_schedule(char const*, char
const*, void*)
0.7% 3.56Ki 0.0% 0 [section .symtab]
0.6% 3.42Ki 0.7% 3.37Ki __kmp_aux_capture_affinity
0.6% 3.23Ki 0.7% 3.16Ki __kmp_partition_places(kmp_team*, int)
0.6% 3.06Ki 0.6% 2.89Ki int __kmp_dispatch_next_algorithm<unsigned
long long>(int, dispatch_private_info_template<unsigned long long>*,
dispatch_shared_info_template<unsigned long long> volatile*, int*, unsigned
long long*, unsigned long long*, traits_t<unsigned long long>::signed_t*,
unsigned long long, unsigned long long)
100.0% 546Ki 100.0% 474Ki TOTAL</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>