mozjpeg-bin
mozjpeg-bin copied to clipboard
Update static Linux build to MozJPEG 4.0.
Statically link with libc too so it works on Alpine and other non-glibc based distros and add a SOURCE_DATE_EPOCH so the build is reproducible.
This will partly fix #56. It will also fix #47. It might help with #35 because I think one of the issues might have been that the previous binary wasn't actually statically linked:
linux-vdso.so.1 (0x00007fffba1af000)
libz.so.1 => /usr/lib/libz.so.1 (0x00007f4e1078c000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007f4e10646000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007f4e1047d000)
/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f4e107ca000)
As you can see, it links dynamically against libc, libm, and zlib.
If you have some free time, please run npm run build-linux
on this branch and
check if the SHA-256 hash of vendor/linux/cjpeg
is the same as what I pushed, which is
36c0bd4308291fbf066d8b7bfbee663c6d2dd37c792183b1113da2ade086e690
Also I don't think the CI is checking this branch since it downloads from GitHub master right? I tested on my own machine though.
@a-vrma # This unsets CMAKE_SHARED_LIBRARY_LINK_C_FLAGS inside CMakeLists.txt,
Do you mean This sets
the value right? because CMakelist does not have that by default.
No, CMake sets it by default. Try adding
include(CMakePrintHelpers)
cmake_print_variables(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS)
anywhere in the CMakeLists.txt and it will output
-- CMAKE_SHARED_LIBRARY_LINK_C_FLAGS="-rdynamic"
This doesn't happen on every CMake project (not mine) but the libjpeg-turbo CMakeLists is very large and very old (version 2.8) and I'm not sure how exactly to debug it so that was my quick fix.
@a-vrma Ok. Now I understand. Thanks for the clarification and great job on the script.
Actually I just found out it gets set in /usr/share/cmake-(version)/Modules/Platform/Linux-GNU.cmake
:
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
# This module is shared by multiple languages; use include blocker.
if(__LINUX_COMPILER_GNU)
return()
endif()
set(__LINUX_COMPILER_GNU 1)
macro(__linux_compiler_gnu lang)
# We pass this for historical reasons. Projects may have
# executables that use dlopen but do not set ENABLE_EXPORTS.
set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-rdynamic")
endmacro()
Cleaned up the script and updated to MozJPEG 4.1.1. This is also a good base upon which to build Linux aarch64 support like in #75 but reproducible.
After merging #80 I think this pull request can be closed or you should updated your pull request to match current main branch.