Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Header variable bug src/as-validator-issue-tag.h #673

Open
hholst80 opened this issue Oct 21, 2024 · 4 comments
Open

Header variable bug src/as-validator-issue-tag.h #673

hholst80 opened this issue Oct 21, 2024 · 4 comments

Comments

@hholst80
Copy link

/~https://github.com/ximion/appstream/blame/221ed8e10b59061d07f6ac01a624ed1e86b3686f/src/as-validator-issue-tag.h#L39

This is a variable defined in a header file. It needs to go into a compilation unit and only one.

@hholst80
Copy link
Author

The problem is in the tests. The library and the test itself will both define the same symbol.

tests/test-validate.c:#include "as-validator-issue-tag.h"
docs/gen-valtag-sections.c:#include "as-validator-issue-tag.h"
docs/meson.build:    '../src/as-validator-issue-tag.h',
compose/asc-globals.c:#include "as-validator-issue-tag.h"
src/as-validator.c:#include "as-validator-issue-tag.h"

@ximion
Copy link
Owner

ximion commented Dec 8, 2024

How are you compiling AppStream? This conflict does not seem to happen with any compiler we test with, and shouldn't since the symbol is hidden in the library, so the linker shouldn't see it.

I have also been unable to reproduce the issue.

@hholst80
Copy link
Author

hholst80 commented Dec 9, 2024

You will likely only be able to trigger this if you attempt to compile with --prefer-static or --default-library=static (or =both).

@hholst80
Copy link
Author

hholst80 commented Dec 9, 2024

I do not know about fancy link level magic like symbol hiding, but from a C code perspective the original post is still valid: We cannot have non-local variables with the same name in two compilation units. In the test we need to refer to the variable as extern or normal C linkage will not work.

Proposed workaround: Can we use a simple #ifdef for the header file, if it is included from a test unit? So, in the test case, its defined as extern, otherwise no action required, keep old definition.

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

No branches or pull requests

2 participants