Skip to content

Build Fails for s390x when using cmake #2719

@R3hankhan123

Description

@R3hankhan123

Problem:

When trying to build aws-lc on s390x using cmake the compilation fails with strncmp due to -Werror=string-compare

Relevant details

AWS-LC commit: (84d06ec)

System information: for linux, below info can be collected by running uname -srvmp

  • CPU architecture: s390x
  • CPU name: s390x
  • OS: Red Hat Enterprise Linux release 9.6 (Plow)

Build log:

[root@b314lp50 build]# make -j$(nproc)
[  0%] Built target boringssl_prefix_symbols
[  3%] Built target jitterentropy
[  4%] Built target fipsmodule
[  5%] Building C object crypto/CMakeFiles/crypto_objects.dir/pem/pem_lib.c.o
/root/aws-lc/crypto/pem/pem_lib.c: In function ‘PEM_read_bio’:
/root/aws-lc/crypto/pem/pem_lib.c:712:11: error: ‘strncmp’ of strings of length 1 and 9 and bound of 9 evaluates to nonzero [-Werror=string-compare]
  712 |       if (strncmp(buf, "-----END ", 9) == 0) {
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/root/aws-lc/crypto/pem/pem_lib.c: At top level:
cc1: note: unrecognized command-line option ‘-Wno-c11-extensions’ may have been intended to silence earlier diagnostics
cc1: all warnings being treated as errors
make[2]: *** [crypto/CMakeFiles/crypto_objects.dir/build.make:1784: crypto/CMakeFiles/crypto_objects.dir/pem/pem_lib.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:206: crypto/CMakeFiles/crypto_objects.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

From our end we were able to resolve the issue by two method

  1. Suppress the error by using the flag CFLAGS += -Wno-error=string-compare

  2. In crypto/pem/pem_lib.c replace strncmp to OPENSSL_memcmp/CRYPTO_memcmp/ memcmp

Both approaches work, but I’d like to ask your preference for an upstream fix:

Would you accept replacing strncmp with memcmp in this case?

Or would you prefer guarding the build flags to suppress this warning?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions