From 9d85d630da7a63b9e5da60431d5201e2e7b5308f Mon Sep 17 00:00:00 2001
From: Thomas Gambier <thomas.gambier@nexedi.com>
Date: Wed, 29 Mar 2023 14:54:34 +0200
Subject: [PATCH] component/zlib: add -fPIC flag to compile on newest Fedora

Fedora 36 and 37 were failing with following message:

cc -shared -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64  -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_LARGEFILE64_SOURCE=1 -o libz.so.1.2.12 adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo  -lc -Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes
/usr/bin/ld: /tmp/ccrAYWgY.ltrans0.ltrans.o: warning: relocation against `zcfree' in read-only section `.text'
/usr/bin/ld: /tmp/ccrAYWgY.ltrans0.ltrans.o: relocation R_X86_64_PC32 against symbol `_length_code' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
---
 component/zlib/buildout.cfg | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/component/zlib/buildout.cfg b/component/zlib/buildout.cfg
index b2dec92f0..d7f5b3399 100644
--- a/component/zlib/buildout.cfg
+++ b/component/zlib/buildout.cfg
@@ -7,3 +7,5 @@ recipe = slapos.recipe.cmmi
 shared = true
 url = https://zlib.net/fossils/zlib-1.2.12.tar.gz
 md5sum = 5fc414a9726be31427b440b434d05f78
+environment =
+  CFLAGS=-fPIC
-- 
2.30.9