Describe the bug
An include order dependency led to this test failure: #2908
Issue tracked to a problem where off_t was getting defined as 4 or 8 bytes, on 32-bit systems, depending upon include order. In the new lrulfu.c file, include order resolved to (only): stdint.h, stdbool.h, server.h. With this ordering, off_t was defined as a 4-byte value. Everywhere else in Valkey, off_t was 8-bytes. This caused a large number of offsets inside valkeyServer to resolve differently.
A linker warning was produced, but we don't currently fail the build because of this.
LINK valkey-server
server.h:2699:28: warning: type of ‘server’ does not match original declaration [-Wlto-type-mismatch]
2699 | extern struct valkeyServer server;
| ^
server.c:104:21: note: ‘server’ was previously declared here
104 | struct valkeyServer server; /* Server global state */
| ^
server.c:104:21: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used
To reproduce
Create a new .c file containing:
#include <stdint.h>
#include <stdbool.h>
#include "server.h"
... write some code that uses `server.`
... maybe check `sizeof(off_t)`
Look for warning at link time.
Expected behavior
- There shouldn't be a problem - compilation should not depend on include order at this level.
- If there is a problem, link should fail (not succeed with warnings)
Additional information
See:
Describe the bug
An include order dependency led to this test failure: #2908
Issue tracked to a problem where
off_twas getting defined as 4 or 8 bytes, on 32-bit systems, depending upon include order. In the newlrulfu.cfile, include order resolved to (only):stdint.h,stdbool.h,server.h. With this ordering,off_twas defined as a 4-byte value. Everywhere else in Valkey,off_twas 8-bytes. This caused a large number of offsets insidevalkeyServerto resolve differently.A linker warning was produced, but we don't currently fail the build because of this.
To reproduce
Create a new
.cfile containing:Look for warning at link time.
Expected behavior
Additional information
See: