Skip to content

Fix builds that don't use cmake (for example clippy)#3631

Merged
stevenengler merged 4 commits intoshadow:mainfrom
stevenengler:fix-clippy-c-builds
Jul 22, 2025
Merged

Fix builds that don't use cmake (for example clippy)#3631
stevenengler merged 4 commits intoshadow:mainfrom
stevenengler:fix-clippy-c-builds

Conversation

@stevenengler
Copy link
Copy Markdown
Contributor

@stevenengler stevenengler commented Jul 19, 2025

Clippy fails to run on newer distros since the build scripts compile C code using a different -std option when building with cmake vs cargo directly. My guess is that the distro defaults to a newer C compiler std than gnu11.

$ (cd src && cargo clippy --all-targets)
[...]
  --- stderr


  error occurred in cc-rs: command did not execute successfully (status code exit status: 1): LC_ALL="C" "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "../../../build/src" "-I" "../../../src" "-DNDEBUG" "-D_GNU_SOURCE" "-o" "/shared/code/old/shadow/src/target/debug/build/logger-604d717f7fc0cf2d/out/db3b6bfb95261072-logger.o" "-c" "logger.c"


warning: build failed, waiting for other jobs to finish...
warning: logger@0.0.0: logger.c:156:18: error: initialization of 'void (*)(Logger *)' {aka 'void (*)(struct _Logger *)'} from incompatible pointer type 'void (*)(void)' [-Wincompatible-pointer-types]
warning: logger@0.0.0:   156 |         .flush = _stderrlogger_flush,
warning: logger@0.0.0:       |                  ^~~~~~~~~~~~~~~~~~~
warning: logger@0.0.0: logger.c:156:18: note: (near initialization for 'stderrLogger.base.flush')
warning: logger@0.0.0: logger.c:96:13: note: '_stderrlogger_flush' declared here
warning: logger@0.0.0:    96 | static void _stderrlogger_flush() {
warning: logger@0.0.0:       |             ^~~~~~~~~~~~~~~~~~~
warning: logger@0.0.0: ToolExecError: command did not execute successfully (status code exit status: 1): LC_ALL="C" "cc" "-O1" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-I" "../../../build/src" "-I" "../../../src" "-DDEBUG" "-Wunused-function" "-D_GNU_SOURCE" "-o" "/shared/code/old/shadow/src/target/debug/build/logger-37127e07d5b11b5f/out/db3b6bfb95261072-logger.o" "-c" "logger.c"
error: failed to run custom build command for `logger v0.0.0 (/shared/code/old/shadow/src/lib/logger)`

This PR fixes the bug in the C code, and moves the -std= option from cmake to the rust build scripts so that we don't run into the situation where the normal build and clippy build use different C standards.

@stevenengler stevenengler self-assigned this Jul 19, 2025
@stevenengler stevenengler added the Component: Tools Peripheral tools like parsing log files or visualizing results label Jul 19, 2025
@github-actions github-actions bot added Component: Libraries Support functions like LD_PRELOAD and logging Component: Testing Unit and integration tests and frameworks Component: Main Composing the core Shadow executable Component: Build Build/install tools and dependencies and removed Component: Tools Peripheral tools like parsing log files or visualizing results labels Jul 19, 2025
@stevenengler stevenengler requested a review from a team July 19, 2025 22:06
This means that other tools like clippy which run the build scripts will
use the same standard library as the main cmake build.
@stevenengler stevenengler force-pushed the fix-clippy-c-builds branch from 38b2bd5 to ac5e4e2 Compare July 20, 2025 04:27
@github-actions github-actions bot added the Component: Documentation In-repository documentation, under docs/ label Jul 20, 2025
@stevenengler stevenengler force-pushed the fix-clippy-c-builds branch from 4292b71 to ac5e4e2 Compare July 20, 2025 04:45
@stevenengler stevenengler merged commit 3c972bc into shadow:main Jul 22, 2025
50 checks passed
@stevenengler stevenengler deleted the fix-clippy-c-builds branch July 22, 2025 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Build Build/install tools and dependencies Component: Documentation In-repository documentation, under docs/ Component: Libraries Support functions like LD_PRELOAD and logging Component: Main Composing the core Shadow executable Component: Testing Unit and integration tests and frameworks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants