Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update static Linux build to MozJPEG 4.0. #57

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

averms
Copy link

@averms averms commented Nov 17, 2020

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

@averms
Copy link
Author

averms commented Nov 17, 2020

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.

@averms averms force-pushed the static_mozjpeg4 branch 3 times, most recently from e8bfff2 to 9bc1591 Compare November 27, 2020 08:37
@vikas5914
Copy link

@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.

@averms
Copy link
Author

averms commented Dec 11, 2020

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.

@vikas5914
Copy link

@a-vrma Ok. Now I understand. Thanks for the clarification and great job on the script.

@averms
Copy link
Author

averms commented Dec 11, 2020

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()

Link in libc too so it works on Alpine and other non-glibc based
distros and add a SOURCE_DATE_EPOCH so the build is reproducible.
@averms
Copy link
Author

averms commented Oct 1, 2022

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.

@MateuszKrawczuk
Copy link
Contributor

After merging #80 I think this pull request can be closed or you should updated your pull request to match current main branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MozJPEG 4 Not working in node:alpine Docker base image
3 participants