Pass -flto flag to the linker (#11350)

Currently, we add -flto to the compile flags only. We are supposed
to add it to the linker flags as well. Clang build fails because of this.

Added a change to add -flto to REDIS_CFLAGS and REDIS_LDFLAGS
if the build optimization flag is -O3. (noopt build will not use -flto)
This commit is contained in:
Ozan Tezcan 2022-10-06 11:26:19 +03:00 committed by GitHub
parent 663fbd3459
commit b08ebff31f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 5 deletions

View File

@ -15,7 +15,11 @@
release_hdr := $(shell sh -c './mkreleasehdr.sh')
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
OPTIMIZATION?=-O3 -flto
OPTIMIZATION?=-O3
ifeq ($(OPTIMIZATION),-O3)
REDIS_CFLAGS+=-flto
REDIS_LDFLAGS+=-flto
endif
DEPENDENCY_TARGETS=hiredis linenoise lua hdr_histogram
NODEPS:=clean distclean

View File

@ -1573,9 +1573,9 @@ REDIS_STATIC void *_quicklistSaver(unsigned char *data, size_t sz) {
* Returns malloc'd value from quicklist */
int quicklistPop(quicklist *quicklist, int where, unsigned char **data,
size_t *sz, long long *slong) {
unsigned char *vstr;
size_t vlen;
long long vlong;
unsigned char *vstr = NULL;
size_t vlen = 0;
long long vlong = 0;
if (quicklist->count == 0)
return 0;
int ret = quicklistPopCustom(quicklist, where, &vstr, &vlen, &vlong,

View File

@ -1028,7 +1028,7 @@ unsigned char *zzlDelete(unsigned char *zl, unsigned char *eptr) {
unsigned char *zzlInsertAt(unsigned char *zl, unsigned char *eptr, sds ele, double score) {
unsigned char *sptr;
char scorebuf[MAX_D2STRING_CHARS];
int scorelen;
int scorelen = 0;
long long lscore;
int score_is_long = double2ll(score, &lscore);
if (!score_is_long)