Module: Tebako::Packager::PatchLibraries
- Defined in:
- lib/tebako/packager/patch_libraries.rb
Overview
Ruby patching definitions (pass2)
Constant Summary collapse
- DARWIN_BREW_LIBS =
rubocop:disable Style/WordArray
[ ["zlib", "z"], ["gdbm", "gdbm"], ["readline", "readline"], ["libffi", "ffi"], ["ncurses", "ncurses"], ["lz4", "lz4"], ["xz", "lzma"], ["libyaml", "yaml"] ].freeze
- DARWIN_BREW_LIBS_PRE_31 =
[["openssl@1.1", "ssl"], ["openssl@1.1", "crypto"]].freeze
- DARWIN_BREW_LIBS_31 =
[["openssl@3", "ssl"], ["openssl@3", "crypto"]].freeze
- DARWIN_DEP_LIBS_1 =
["tfs", "tebako_dirent_helper_c"].freeze
- DARWIN_DEP_LIBS_2 =
Referenced by full path from the vcpkg triplet lib dir (see darwin_libraries): Apple ld does not implement the GNU-style -l:
library search, so -l:libX.a refs do not resolve. ["dwarfs_reader", "dwarfs_common", "dwarfs_metadata_legacy", "dwarfs_decompressor", "flatbuffers", "zip", "fmt", "xxhash", "zstd", "brotlidec", "brotlienc", "brotlicommon", "bz2", "boost_filesystem", "boost_chrono"].freeze
- COMMON_LINUX_LIBRARIES =
--start-group/--end-group around the libtfs + transitive static archives: the dwarfs reader set has circular member-level references that trip GNU ld's single-pass scanning when built with clang (compression registrar). libtfs (libtfs.a + its pure-C dirent helper) and the transitive static set resolved by vcpkg into deps/vcpkg_installed/
/lib: the dwarfs reader side, flatbuffers, zip and the C++ support libs. Compression codecs register explicitly (compression_registry ctor), so no --whole-archive compression lib is needed anymore. [ "-Wl,--push-state,--whole-archive -l:libtebako-fs.a -Wl,--pop-state", "-l:libtfs.a", "-l:libtebako_dirent_helper_c.a", "-l:libdwarfs_reader.a", "-l:libdwarfs_common.a", "-l:libdwarfs_metadata_legacy.a", "-l:libdwarfs_decompressor.a", "-l:libflatbuffers.a", "-l:libzip.a", "-l:libfmt.a", "-l:libxxhash.a", "-l:libboost_filesystem.a", "-l:libboost_chrono.a" ].freeze
- COMMON_ARCHIEVE_LIBRARIES =
[ "-l:liblz4.a", "-l:libz.a", "-l:libzstd.a", "-l:libbrotlienc.a", "-l:libbrotlidec.a", "-l:libbrotlicommon.a", "-l:liblzma.a", "-l:libbz2.a" ].freeze
- LINUX_GNU_LIBRARIES =
[ "-l:libacl.a", "-l:libssl.a", "-l:libcrypto.a", "-l:libgdbm.a", "-l:libreadline.a", "-l:libtinfo.a", "-l:libffi.a", "-l:libncurses.a", "-l:libjemalloc.a", "-l:libcrypt.a", "-l:libanl.a", "LIBYAML", "-l:libutil.a", "-l:libstdc++.a", "-lgcc_eh", "-l:liblzma.a", "-l:librt.a", "-ldl", "-lpthread", "-lm" ].freeze
- LINUX_MUSL_LIBRARIES =
[ "-l:libacl.a", "-l:libssl.a", "-l:libcrypto.a", "-l:libreadline.a", "-l:libgdbm.a", "-l:libffi.a", "-l:libncurses.a", "-l:libjemalloc.a", "-l:libcrypt.a", "LIBYAML", "-l:librt.a", "-l:libstdc++.a", "-lgcc_eh", "-l:liblzma.a", "-ldl", "-lpthread" ].freeze
- MSYS_LIBRARIES =
[ "-l:liblz4.a", "-l:libz.a", "-l:libzstd.a", "-l:liblzma.a", "-l:libncurses.a", "-l:liblzma.a", "-l:libiberty.a", "LIBYAML", "-l:libffi.a", "-l:libstdc++.a", "-l:libdl.a", "-static-libgcc", "-static-libstdc++", "-l:libssl.a", "-l:libcrypto.a", "-l:libz.a", "-l:libwinpthread.a", "-lcrypt32", "-lshlwapi", "-lwsock32", "-liphlpapi", "-limagehlp", "-lbcrypt", "-lole32", "-loleaut32", "-luuid", "-lws2_32" ].freeze
Class Method Summary collapse
- .darwin_libraries(deps_lib_dir, ruby_ver, _with_compression) ⇒ Object
- .linux_gnu_libraries(ruby_ver, with_compression) ⇒ Object
- .linux_libraries(libraries, ruby_ver, _with_compression) ⇒ Object
- .linux_musl_libraries(ruby_ver, with_compression) ⇒ Object
-
.mlibs(ostype, deps_lib_dir, ruby_ver, with_compression) ⇒ Object
.....................................................
- .msys_libraries(ruby_ver, with_compression) ⇒ Object
- .process_brew_libs!(libs, brew_libs) ⇒ Object
Class Method Details
.darwin_libraries(deps_lib_dir, ruby_ver, _with_compression) ⇒ Object
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/tebako/packager/patch_libraries.rb', line 140 def darwin_libraries(deps_lib_dir, ruby_ver, _with_compression) libs = String.new DARWIN_DEP_LIBS_1.each { |lib| libs << "#{deps_lib_dir}/lib#{lib}.a " } process_brew_libs!(libs, ruby_ver.ruby31? ? DARWIN_BREW_LIBS_31 : DARWIN_BREW_LIBS_PRE_31) process_brew_libs!(libs, DARWIN_BREW_LIBS) # The vcpkg set by full path: Apple ld does not implement -l:<filename> vcpkg_lib_dir = Dir.glob(File.join(deps_lib_dir, "..", "vcpkg_installed", "*", "lib")).min DARWIN_DEP_LIBS_2.each { |lib| libs << "#{vcpkg_lib_dir}/lib#{lib}.a " } # No allocator link: brew's static libjemalloc.a crashes tebako # binaries at startup on the XCode 15.4 runners (je_arena_ralloc # SEGV at builtin init), and the dylib fails the test_101 # no-shared-libs assertion. System malloc until a properly built # static jemalloc ships with libtfs-deps. "-ltebako-fs #{libs}-lc++ -lc++abi" end |
.linux_gnu_libraries(ruby_ver, with_compression) ⇒ Object
107 108 109 110 111 |
# File 'lib/tebako/packager/patch_libraries.rb', line 107 def linux_gnu_libraries(ruby_ver, with_compression) libraries = ["-Wl,--start-group"] + COMMON_LINUX_LIBRARIES + COMMON_ARCHIEVE_LIBRARIES + ["-Wl,--end-group"] + LINUX_GNU_LIBRARIES linux_libraries(libraries, ruby_ver, with_compression) end |
.linux_libraries(libraries, ruby_ver, _with_compression) ⇒ Object
119 120 121 122 123 124 125 126 127 128 |
# File 'lib/tebako/packager/patch_libraries.rb', line 119 def linux_libraries(libraries, ruby_ver, _with_compression) libraries.map! do |lib| if lib == "LIBYAML" PatchHelpers.yaml_reference(ruby_ver) else lib end end libraries.join(" ") end |
.linux_musl_libraries(ruby_ver, with_compression) ⇒ Object
113 114 115 116 117 |
# File 'lib/tebako/packager/patch_libraries.rb', line 113 def linux_musl_libraries(ruby_ver, with_compression) libraries = ["-Wl,--start-group"] + COMMON_LINUX_LIBRARIES + COMMON_ARCHIEVE_LIBRARIES + ["-Wl,--end-group"] + LINUX_MUSL_LIBRARIES linux_libraries(libraries, ruby_ver, with_compression) end |
.mlibs(ostype, deps_lib_dir, ruby_ver, with_compression) ⇒ Object
..................................................... Notes re linux libraries
- -lgcc_eh assumes -static-libgcc (applied in CMakeLists.ext, RUBY_C_FLAGS)
- -static-libstdc++ did not work, not sure why [TODO ?]
- When clang is used linker links libraries specified in exensions in such way that they are linked shared (libz, libffi, libreadline, libncurses, libtinfo, ... ) Using stuff like -l:libz.a does not help; there is a reference to libz.so anyway. This is fixed by ext/extmk.rb patch [TODO ?] .....................................................
168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/tebako/packager/patch_libraries.rb', line 168 def mlibs(ostype, deps_lib_dir, ruby_ver, with_compression) scmb = ScenarioManagerBase.new(ostype) if scmb.msys? msys_libraries(ruby_ver, with_compression) elsif scmb.macos? darwin_libraries(deps_lib_dir, ruby_ver, with_compression) elsif scmb.musl? linux_musl_libraries(ruby_ver, with_compression) else linux_gnu_libraries(ruby_ver, with_compression) end end |
.msys_libraries(ruby_ver, with_compression) ⇒ Object
130 131 132 133 134 |
# File 'lib/tebako/packager/patch_libraries.rb', line 130 def msys_libraries(ruby_ver, with_compression) libraries = with_compression ? ["-Wl,-Bstatic"] : [] libraries = libraries + COMMON_LINUX_LIBRARIES + MSYS_LIBRARIES linux_libraries(libraries, ruby_ver, with_compression) end |
.process_brew_libs!(libs, brew_libs) ⇒ Object
136 137 138 |
# File 'lib/tebako/packager/patch_libraries.rb', line 136 def process_brew_libs!(libs, brew_libs) brew_libs.each { |lib| libs << "#{PatchHelpers.get_prefix_macos(lib[0]).chop}/lib/lib#{lib[1]}.a " } end |