kevinboone / solunar2

A command-line utility for Linux, for display sunrise/set and similar information
GNU General Public License v3.0
19 stars 4 forks source link

Building on Ubuntu 20.04 #4

Closed DavidAPease closed 5 months ago

DavidAPease commented 3 years ago

Ran into problems building on Ubuntu 20.04 (GCC version 9.3.0). I am posting my work-arounds here for any others that hit these problems:

1 Unused return value warning from write() and other functions was being flagged as an error while building in the klib directory: In ./klib/Makefile, remove -Werror flag to convert "unused function return value" error back to warning.

  1. Unresolved calls to trig functions in ld: In main ./Makefile, move $(LIBS) from the middle of the $(CC) line to the end, so that libmath is searched after unresolved references have been encountered.
kevinboone commented 3 years ago

Thanks for pointing this out. There's an ongoing problem, here: I always use "-Werror" in my builds, because I want to trap every warning that might potentially be relevant. Unfortunately, the kinds of things that gcc thinks are worthy of reporting as warnings, with specific command-line settings, seems to be somewhat variable. My version isn't complaining about ignoring the return value from write(), but arguably this is something I ought to look into. It's possible that I should be checking this return value.

The same applies to the library search order used by the GNU linker. It does seem to cause any problem for me when I change the order in the way you describe; but when I change anything like this, even slightly, I get a barrage of complaints ;)

So, unless it's causing you a lot of inconvenience, I'd rather just leave this as a helpful comment. I could remove the "-Werror" from master if it's causing a lot of annoyance -- I have had to do this on some of my other repositories.

jayascript commented 3 years ago

Just chiming in that I had this exact same error this morning. I almost went back to the previous version of this package because I couldn't get this one to install. The workaround provided by @DavidAPease was quick and solved the problem easily. Please do look into this and consider updating the master branch as it could deter potential users like me from installing the newer version of this application.

kevinboone commented 3 years ago

Sigh. I've removed -Werror from the build. I can always put it back in, in my local installation. I hate doing this, because I like the assurance that no warnings are sneaking past. At the same time, there's no consistency among GCC versions about what actually constitutes a warning :/

cernyhonza commented 2 years ago

Hi, there is still -Werror in klib/Makefile. I;ve just got following error with gcc 12.2.0:

src/kzipfile.c:700:9: error: pointer ‘s_path’ may be used after ‘free’ [-Werror=use-after-free]
  700 |         klog_debug (KLOG_CLASS, "zip_extract_all: could not create directory %s\n",
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  701 |           s_path);
      |           ~~~~~~~
src/kzipfile.c:694:7: note: call to ‘free’ here
  694 |       free (s_path);
      |       ^~~~~~~~~~~~~
cc1: all warnings being treated as errors
DavidAPease commented 2 years ago

That looks like a valid error to me.  s_path is allocated, then immediately freed, then potentially used in the klog_debug call. I'd move the free( call after the klog_debug( call.

        -David

On 11/12/22 06:01AM, Jan Cerny wrote:

Hi, there is still -Werror in klib/Makefile. I;ve just got following error with gcc 12.2.0:

|src/kzipfile.c:700:9: error: pointer ‘s_path’ may be used after ‘free’ [-Werror=use-after-free] 700 | klog_debug (KLOG_CLASS, "zip_extract_all: could not create directory %s\n", | ^~~~~~~~~~~~~~~~~~~ 701 | s_path); | ~~~ src/kzipfile.c:694:7: note: call to ‘free’ here 694 | free (s_path); | ^~~~~ cc1: all warnings being treated as errors |

— Reply to this email directly, view it on GitHub https://github.com/kevinboone/solunar2/issues/4#issuecomment-1312483994, or unsubscribe https://github.com/notifications/unsubscribe-auth/AENCOM4Q5FMQXNJK3AMJD2TWH6PKBANCNFSM4ZJTDL2A. You are receiving this because you were mentioned.Message ID: @.***>

kevinboone commented 2 years ago

I'm reluctant to remove -Werror because doing so allows errors like this -- which are entirely my own -- to escape unnoticed. In this case, the file containing the error is, in fact, unused, and I've removed the entire file.

kevinboone commented 5 months ago

Closing because I removed -Werror, by popular request.