Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"make check" fails to build cleanly with extra warnings enabled #1628

Closed
Patater opened this issue May 14, 2018 · 7 comments
Closed

"make check" fails to build cleanly with extra warnings enabled #1628

Patater opened this issue May 14, 2018 · 7 comments
Labels
bug component-platform Portability layer and build scripts

Comments

@Patater
Copy link
Contributor

Patater commented May 14, 2018

Description

  • Type: Bug
  • Priority: Minor

Bug

mbed TLS build:
Version: 2.9.0

Expected behavior
make check CFLAGS="-O2 -Wall -Wextra -Werror" should not fail to build.

Actual behavior

make check CFLAGS="-O2 -Wall -Wextra -Werror" fails to build, due to warnings like the following:

  CC    test_suite_cipher.aes.c
helpers.function:224:13: error: unused function 'hexify'
      [-Werror,-Wunused-function]
static void hexify( unsigned char *obuf, const unsigned char *ibuf, int len )
            ^
helpers.function:278:23: error: unused function 'unhexify_alloc'
      [-Werror,-Wunused-function]
static unsigned char *unhexify_alloc( const char *ibuf, size_t *olen )
                      ^
helpers.function:329:12: error: unused function 'rnd_zero_rand'
      [-Werror,-Wunused-function]
static int rnd_zero_rand( void *rng_state, unsigned char *output, size_t len )
           ^
helpers.function:356:12: error: unused function 'rnd_buffer_rand'
      [-Werror,-Wunused-function]
static int rnd_buffer_rand( void *rng_state, unsigned char *output, size_t len )
           ^
helpers.function:402:12: error: unused function 'rnd_pseudo_rand'
      [-Werror,-Wunused-function]
static int rnd_pseudo_rand( void *rng_state, unsigned char *output, size_t len )
           ^
5 errors generated.
make[1]: *** [test_suite_cipher.aes] Error 1

Steps to reproduce

Run make check CFLAGS="-O2 -Wall -Wextra -Werror".

@Patater Patater added the bug label May 14, 2018
@Patater Patater added component-platform Portability layer and build scripts Arm Contribution labels Jun 8, 2018
@gilles-peskine-arm
Copy link
Contributor

make check CFLAGS=-Werror does the same thing, except that it disables the warnings on unused functions and values (we turn on -Wall -Wextra in the default compiler flags). The files test_suite_*.c are automatically generated, so it makes sense to generate code for sometimes-used functions and let the compiler eliminate the ones that aren't used in a specific test.

@ciarmcom
Copy link

ARM Internal Ref: IOTSSL-2524

@mpg
Copy link
Contributor

mpg commented Sep 19, 2018

@Patater I can't reproduce this on my machine. Steps used:

make clean
git checkout mbedtls-2.9.0
make check CFLAGS="-O2 -Wall -Wextra -Werror"

Tools versions:

% gcc --version | head -n1  
gcc (Ubuntu 5.5.0-12ubuntu1~16.04) 5.5.0 20171010
% make --version | head -n1
GNU Make 4.1

Can you still reproduce on your machine? If so, any idea what could explain the discrepancy?

Note: we do try to suppress this warning in tests, because as Gilles mentioned, we don't really care about it in generated code.

% grep CFLAGS tests/Makefile | uniq
CFLAGS  ?= -O2
WARNING_CFLAGS ?= -Wall -W -Wdeclaration-after-statement -Wno-unused-function -Wno-unused-value
LOCAL_CFLAGS = $(WARNING_CFLAGS) -I../include -D_FILE_OFFSET_BITS=64
LOCAL_CFLAGS += -g3
        $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $<      $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@

@Patater
Copy link
Contributor Author

Patater commented Oct 3, 2018

I was using clang.

@mpg
Copy link
Contributor

mpg commented Oct 4, 2018

Could reproduce now. It looks like the issue would be fixed by changing each occurrence of $(LOCAL_CFLAGS) $(CFLAGS) to $(CFLAGS) $(LOCAL_CFLAGS) in tests/Makefile.

Or, as Gilles said, in the meantime you can just use CFLAGS='-Werror -O2' which does the same as your invocation except it works.

@simonbutcher
Copy link
Contributor

I've just realised I've created the same bug over again because I encountered it in another way. See #2051.

I've already raised a PR to fix this with PR #2053.

simonbutcher added a commit to simonbutcher/mbedtls that referenced this issue Apr 18, 2019
simonbutcher added a commit to simonbutcher/mbedtls that referenced this issue Apr 18, 2019
gilles-peskine-arm added a commit to gilles-peskine-arm/mbedtls that referenced this issue Jun 19, 2019
Patater added a commit that referenced this issue Jun 21, 2019
* origin/pr/2320:
  Clarify ChangeLog entry for fix to #1628
  Add Changelog entry for clang test-ref-configs.pl fix
  Enable more compiler warnings in tests/Makefile
  Change file scoping of test helpers.function
Patater added a commit that referenced this issue Jun 21, 2019
* origin/pr/2053:
  Clarify ChangeLog entry for fix to #1628
  Add Changelog entry for clang test-ref-configs.pl fix
  Enable more compiler warnings in tests/Makefile
  Change file scoping of test helpers.function
Patater added a commit that referenced this issue Jun 21, 2019
* origin/pr/2053:
  Clarify ChangeLog entry for fix to #1628
  Add Changelog entry for clang test-ref-configs.pl fix
  Enable more compiler warnings in tests/Makefile
  Change file scoping of test helpers.function
simonbutcher pushed a commit to simonbutcher/mbedtls that referenced this issue Jul 17, 2019
* restricted/pr/608:
  programs: Make `make clean` clean all programs always
  ssl_tls: Enable Suite B with subset of ECP curves
  windows: Fix Release x64 configuration
  timing: Remove redundant include file
  net_sockets: Fix typo in net_would_block()
  Add all.sh component that exercises invalid_param checks
  Remove mbedtls_param_failed from programs
  Make it easier to define MBEDTLS_PARAM_FAILED as assert
  Make test suites compatible with #include <assert.h>
  Pass -m32 to the linker as well
  Update library to 2.16.2
  Use 'config.pl baremetal' in all.sh
  Clarify ChangeLog entry for fix to Mbed-TLS#1628
  Fix Mbed-TLS#2370, minor typos and spelling mistakes
  Add Changelog entry for clang test-ref-configs.pl fix
  Enable more compiler warnings in tests/Makefile
  Change file scoping of test helpers.function
@yanesca
Copy link
Contributor

yanesca commented Aug 12, 2019

Fixed by #2053, therefore closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug component-platform Portability layer and build scripts
Projects
None yet
Development

No branches or pull requests

6 participants