unikraft / lib-newlib

Unikraft port of newlib, a C standard library
Other
5 stars 23 forks source link

newlib/include: Fix `gcc-11` compilation warning #13

Closed craciunoiuc closed 2 years ago

craciunoiuc commented 3 years ago

This pull request fixes a deprecated attribute that gives a repeated warning when compiling with gcc-11. This does not affect older versions of gcc (starting with 4.3.0), as the functionality was already present.

From the gcc documentation:

 The allocated size is either the value of the single function argument specified or the product of the two function arguments specified. 

This is the only place where alloc_size is used, but because the header is included everywhere, the warning is repeated hundreds of times.

The fix is already implemented in newer versions of newlib so this will fail to apply when bumping the version.

Signed-off-by: Cezar Craciunoiu cezar.craciunoiu@gmail.com

FredrikBakken commented 3 years ago

Hello @craciunoiuc!

I am currently in the process of trying to replicate these warning messages, but have so far been unsuccessful in doing so. My GCC version is as follows:

$ gcc --version
gcc (Ubuntu 11.1.0-1ubuntu1~21.04) 11.1.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

In my initial tests I've been trying to use the helloworld-cpp project to try to force these warnings, but they do not seem to appear. I've attached the output I get from executing the make command on the application with all underlying resources (unikraft and external libs) set to their respective staging branches. build_v11.1.log

craciunoiuc commented 3 years ago

Hello @craciunoiuc!

I am currently in the process of trying to replicate these warning messages, but have so far been unsuccessful in doing so. My GCC version is as follows:

$ gcc --version
gcc (Ubuntu 11.1.0-1ubuntu1~21.04) 11.1.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

In my initial tests I've been trying to use the helloworld-cpp project to try to force these warnings, but they do not seem to appear. I've attached the output I get from executing the make command on the application with all underlying resources (unikraft and external libs) set to their respective staging branches. build_v11.1.log

Hey @FredrikBakken,

Can you try using gcc-11.2.0? This is what I used when I got the warnings. (also, move to staging again, the verbose output was fixed)

gcc (Ubuntu 11.2.0-7ubuntu2) 11.2.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I'll test it again with the staging branch and come back to you.

Cezar

-- Update:

I'm still getting the issue with the latest staging.

I am compiling a helloworld app and including newlib in it.

I couldn't find any fix related to attributes from gcc-11.1.0 to gcc-11.2.0, but still, try to upgrade to this version and test again.

razvand commented 2 years ago

Approved-by: Razvan Deaconescu razvan.deaconescu@cs.pub.ro