-
Type:
Enhancement
-
Resolution: Fixed
-
Priority:
P4
-
Affects Version/s: 25, 26
-
Component/s: infrastructure
-
b26
-
generic
-
linux
Identical code folding can reduce the size of some libs, especially libjvm. However not all linkers support the flag/feature so we have to limit it to some environments.
See for example :
https://manpages.debian.org/testing/lld-7/ld.lld-7.1
https://manpages.ubuntu.com/manpages/jammy/man1/ld.lld-11.1.html
From what I see, the gold linker and the ld.lld (ELF linker from the LLVM project) support the flag.
sizes of libjvm.so with / without -icf=all (gcc 13.2.0 is used for compilation)
linux aarch64 : 25888 / 27112 K
linux x86_64 : 27952 / 29072 K
(on linuxppc64le the gold linker seems to be available only on very recent distros, so for now I did not measure lib sizes there)
(for most other native libs the identical code folding has no effect, because there is nothing to fold)
something similar seems to be used already for MSVC
https://github.com/openjdk/jdk/blob/56a27d11971d935e8b28ac9d701cf9890014a949/make/autoconf/flags-ldflags.m4#L89
BASIC_LDFLAGS_JVM_ONLY="-opt:icf,8 -subsystem:windows"
See the icf doc at https://learn.microsoft.com/en-us/cpp/build/reference/opt-optimizations?view=msvc-170
See for example :
https://manpages.debian.org/testing/lld-7/ld.lld-7.1
https://manpages.ubuntu.com/manpages/jammy/man1/ld.lld-11.1.html
From what I see, the gold linker and the ld.lld (ELF linker from the LLVM project) support the flag.
sizes of libjvm.so with / without -icf=all (gcc 13.2.0 is used for compilation)
linux aarch64 : 25888 / 27112 K
linux x86_64 : 27952 / 29072 K
(on linuxppc64le the gold linker seems to be available only on very recent distros, so for now I did not measure lib sizes there)
(for most other native libs the identical code folding has no effect, because there is nothing to fold)
something similar seems to be used already for MSVC
https://github.com/openjdk/jdk/blob/56a27d11971d935e8b28ac9d701cf9890014a949/make/autoconf/flags-ldflags.m4#L89
BASIC_LDFLAGS_JVM_ONLY="-opt:icf,8 -subsystem:windows"
See the icf doc at https://learn.microsoft.com/en-us/cpp/build/reference/opt-optimizations?view=msvc-170
- causes
-
JDK-8372705 The riscv-64 cross-compilation build is failing in the CI
-
- Resolved
-
- links to
-
Commit(master)
openjdk/jdk/4ae2f31f
-
Review(master)
openjdk/jdk/28236