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

Unable to install without building shared library #1387

Open
mylovesaber opened this issue Mar 30, 2024 · 2 comments
Open

Unable to install without building shared library #1387

mylovesaber opened this issue Mar 30, 2024 · 2 comments

Comments

@mylovesaber
Copy link

Prepare musl-gcc static version

musl-gcc:

cd ~
wget https://musl.libc.org/releases/musl-1.2.5.tar.gz
tar xfv musl-1.2.5.tar.gz
mkdir -p ~/musl-1.2.5/build
cd ~/musl-1.2.5/build
../configure \
--prefix=$HOME/musl \
--exec-prefix=$HOME/musl \
--syslibdir=$HOME/musl/lib \
--disable-shared
make -j$(nproc)
make install
cd ~

lz4 static build

Makefile

mkdir -p sources
wget -P ~/sources https://github.com/lz4/lz4/releases/download/v1.9.4/lz4-1.9.4.tar.gz
tar xfv lz4-1.9.4.tar.gz
cd lz4-1.9.4
make -j$(nproc) liblz4.a \
CC="musl-gcc -static" \
CFLAGS="-I/home/build/musl/include -O3" \
LDFLAGS="-Wl,--rpath=/home/build/musl/lib"

Everything works fine.

Then, I'm not able to install static build only. It always continue to build shared lib.
Am I ignore something?

CMake

Cmake always use GNU gcc from system instead of specified musl-gcc(It shows musl is ignored)

CC="musl-gcc -static" cmake -DCMAKE_INSTALL_PREFIX=/home/build/musl \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_C_COMPILER=musl-gcc
# or
CC=/home/build/musl/bin/musl-gcc cmake -DCMAKE_INSTALL_PREFIX=/home/build/musl \
-DBUILD_SHARED_LIBS=OFF

the command above perform the same output.

Other info

System (please complete the following information):

  • OS: fedora-server 38
  • Compiler : musl-gcc(static)
  • Build System Makefile
@t-mat
Copy link
Contributor

t-mat commented Mar 30, 2024

Hi @mylovesaber,

EDIT 2024-03-31 : This is a totally wrong answer. Please take a look next post.

Wrong answer

In my environment, I have no issue with musl-gcc. make liblz4.a just build static library.

cd
git clone --depth 1 --branch v1.9.4 https://github.com/lz4/lz4.git lz4-issue-1387
cd lz4-issue-1387

git log -1
# commit 5ff839680134437dbf4678f3d0c7b371d84f4964 (HEAD, tag: v1.9.4, origin/release)

CC=musl-gcc LDFLAGS=-static make clean liblz4.a
# Cleaning completed
# make[1]: Entering directory '/home/user/lz4-issue-1387/lib'
# compiling static library
# make[1]: Leaving directory '/home/user/lz4-issue-1387/lib'

uname -a
# Linux def7 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
cat /etc/lsb-release
# DISTRIB_ID=Ubuntu
# DISTRIB_RELEASE=22.04
# DISTRIB_CODENAME=jammy
# DISTRIB_DESCRIPTION="Ubuntu 22.04.3 LTS"
musl-gcc --version
# x86_64-linux-gnu-gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

Could you try make clean liblz4.a without CC, CFLAGS, LDFLAGS and observe the result?

@t-mat
Copy link
Contributor

t-mat commented Mar 31, 2024

Sorry. I misunderstand your issue. BUILD_SHARED, DESTDIR, and PREFIX settings will help you. For example:

rm -fR ~/mylz4-issue-1387-artifact
mkdir  ~/mylz4-issue-1387-artifact

cd
git clone --depth 1 --branch v1.9.4 https://github.com/lz4/lz4.git lz4-issue-1387

cd ~/lz4-issue-1387
make -C lib clean install BUILD_SHARED=no DESTDIR=~/mylz4-issue-1387-artifact PREFIX=

# make: Entering directory '/mnt/projects/lz4/lib'
# Cleaning library completed
# compiling static library
# creating pkgconfig
# Installing libraries in /home/user/mylz4/lib
# Installing headers in /home/user/mylz4/include
# lz4 libraries installed
# make: Leaving directory '/mnt/projects/lz4/lib'

tree ~/mylz4-issue-1387-artifact

# /home/user/mylz4-issue-1387-artifact
# ├── bin
# ├── include
# │   ├── lz4.h
# │   ├── lz4file.h
# │   ├── lz4frame.h
# │   ├── lz4frame_static.h
# │   └── lz4hc.h
# └── lib
#     ├── liblz4.a
#     └── pkgconfig
#         └── liblz4.pc
# 
# 4 directories, 7 files

note: Current version of lib/README.md#makefile-variables says it generates libzstd but of course this is a typo. Actually it will generate liblz4.

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

No branches or pull requests

2 participants