Skip to content

Conversation

@hbrodin
Copy link

@hbrodin hbrodin commented Dec 19, 2025

configure.ac unconditionally overwrote CFLAGS, ignoring user-provided flags. Running CFLAGS="-O3 -march=native" ./configure had no effect.

Fix by using LIBMODBUS_CFLAGS via AM_CFLAGS in Makefile.am, following standard autoconf/automake conventions. User CFLAGS are now appended last and can override project defaults.

Behavior:

  • ./configure : -O2 (unchanged)
  • ./configure --enable-debug : -g -O0 (unchanged)
  • CFLAGS="-O3" ./configure : -O3 (now respected)
  • CFLAGS="-O3" ./configure --enable-debug : -O3 (user priority)

Also removes unused CXXFLAGS handling (pure C library).

Closes #830.

This will also allow proper coverage tracking on oss-fuzz (https://introspector.oss-fuzz.com/project-profile?project=libmodbus). Currently, coverage is only collected for the harness code. This change should enable coverage tracking for all code.

configure.ac unconditionally overwrote CFLAGS, ignoring user-provided
flags. Running `CFLAGS="-O3 -march=native" ./configure` had no effect.

Fix by using LIBMODBUS_CFLAGS via AM_CFLAGS in Makefile.am, following
standard autoconf/automake conventions. User CFLAGS are now appended
last and can override project defaults.

Behavior:
- ./configure                             : -O2 (unchanged)
- ./configure --enable-debug              : -g -O0 (unchanged)
- CFLAGS="-O3" ./configure                : -O3 (now respected)
- CFLAGS="-O3" ./configure --enable-debug : -O3 (user priority)

Also removes unused CXXFLAGS handling (pure C library).
@cla-bot
Copy link

cla-bot bot commented Dec 19, 2025

We require contributors to sign our Contributor License Agreement. In order for us to review and merge your code, please fill https://forms.gle/5635zjphDo5JEJQSA to get added. Your document will be manually checked by the maintainer. Be patient...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CFLAGS/CXXFLAGS assignment disregard user provided values

1 participant