mesonbuild / mesonbuild/meson

C unity builds are not reproducible if the macro __FILE__ is used

Open
#7,262 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
6.6k
Forks
1.9k
Avg merge
2d 6h
Merged PRs (30d)
33

Description

**Describe the bug**
Unity builds of C source files are not reproducible if the macro \_\_FILE\_\_ is used

**To Reproduce**
Here's a minimal Meson project exhibiting the issue.
`meson.build` content:

project('repro', 'c', default_options: ['unity=on'])
executable('repro', sources: 'repro.c')

`repro.c` content:

#include
int main()
{
printf("%s", __FILE__);
}

**Expected behavior**
Building the example project should create an executable named `repro` which, when executed, prints

../repro.c

The actual generated executable prints the full path, rendering the build not reproducible.

**System parameters**
I verified the issue with the following system parameters:

* OS: Xubuntu 20.04
* Meson versions: 0.54.1 and 0.54.2
* Compilers: clang 10 and gcc 9.3
* Python version: 3.8.2
* Ninja version: 1.10.0

Contributor guide

Open the contributing guide

Research direction

Start with the minimal project in meson.build and repro.c, then reproduce the unity build using the listed Meson, compiler, and Ninja versions. Trace how the unity build handles __FILE__. Done means the generated repro executable prints ../repro.c rather than the full source path.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.