Skip to content

[BUG] Ignored linker warnings led to test failures #2938

Description

@JimB123

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

  1. There shouldn't be a problem - compilation should not depend on include order at this level.
  2. If there is a problem, link should fail (not succeed with warnings)

Additional information

See:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions