Skip to content

build: Fix compilation with ld.lld#2094

Merged
lgritz merged 1 commit intoAcademySoftwareFoundation:mainfrom
AngryLoki:ld-lld
Mar 19, 2026
Merged

build: Fix compilation with ld.lld#2094
lgritz merged 1 commit intoAcademySoftwareFoundation:mainfrom
AngryLoki:ld-lld

Conversation

@AngryLoki
Copy link
Contributor

Description

When using Clang 18<->22 with ld.lld, build fails with:

clang++ -Wl,--version-script=.../hidesymbols.map -o lib/liboslcomp.so.1.13.7 ...
ld.lld: error: version script assignment of 'global' to symbol 'test_shade' failed: symbol not defined

The issue is that test_shade does not belong to liboslcomp, instead it belongs to libtestshade, and ld.lld actually checks that and fails. The minimal fix is to remove test_shade from hidesymbols.map, the slightly better way is to create a separate symbols map for libtestshade.

See also: https://bugs.gentoo.org/929091

Tests

Not required.

Checklist:

  • I have read the contribution guidelines.
  • I have updated the documentation, if applicable.
  • I have ensured that the change is tested somewhere in the testsuite (adding new test cases if necessary).
  • My code follows the prevailing code style of this project. If I haven't
    already run clang-format v17 before submitting, I definitely will look at
    the CI test that runs clang-format and fix anything that it highlights as
    being nonconforming.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Mar 19, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: AngryLoki / name: Sv. Lockal (58abd4d)

Comment on lines +115 to +118
set_property (TARGET libtestshade
APPEND PROPERTY LINK_FLAGS
-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/testshade_symbols.map)
endif ()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was expecting this to fail on Windows, but it didn't. What's going on? Is cmake smart enough to know that that these linker flags only apply to some platforms and don't put them on the link line elsewher?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only place where VISIBILITY_MAP_COMMAND is defined is:

if (${CMAKE_CXX_VISIBILITY_PRESET} STREQUAL "hidden" AND VISIBILITY_MAP_FILE AND
(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) AND
(CMAKE_SYSTEM_NAME MATCHES "Linux|kFreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "GNU"))
# Linux/FreeBSD/Hurd: also hide all the symbols of dependent libraries
# to prevent clashes if an app using this project is linked against
# other versions of our dependencies.
set (VISIBILITY_MAP_COMMAND "-Wl,--version-script=${VISIBILITY_MAP_FILE}")
endif ()

Which is Linux/FreeBSD/Hurd, not even Cygwin/mingw.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see! So the if (VISIBILITY_MAP_COMMAND) is already implicitly guarding by platform. Great.

@lgritz
Copy link
Collaborator

lgritz commented Mar 19, 2026

You will need a DCO sign-off. The easiest way to do that is:

git commit --amend -s
git push origin ld-lld --force

We're experiencing a couple spuriously failing CI jobs which are not related to your changes (you can tell because they fail while setting up dependencies, not while building OSL itself). We won't let that hold up merging this PR if everything else is ok.

When using Clang 18<->22 with ld.lld, build fails with:
```
clang++ -Wl,--version-script=.../hidesymbols.map -o lib/liboslcomp.so.1.13.7 ...
ld.lld: error: version script assignment of 'global' to symbol 'test_shade' failed: symbol not defined
```

The issue is that test_shade does not belong to liboslcomp, instead it belongs to libtestshade,
and ld.lld actually checks that and fails. The minimal fix is to remove test_shade from hidesymbols.map,
the slightly better way is to create a separate symbols map for libtestshade.

See also: https://bugs.gentoo.org/929091

Signed-off-by: Sv. Lockal <lockalsash@gmail.com>
@AngryLoki
Copy link
Contributor Author

git commit --amend -s

Done

Copy link
Collaborator

@lgritz lgritz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the fix

@lgritz lgritz merged commit d282e12 into AcademySoftwareFoundation:main Mar 19, 2026
24 of 27 checks passed
lgritz pushed a commit to lgritz/OpenShadingLanguage that referenced this pull request Mar 20, 2026
When using Clang 18<->22 with ld.lld, build fails with:
```
clang++ -Wl,--version-script=.../hidesymbols.map -o lib/liboslcomp.so.1.13.7 ...
ld.lld: error: version script assignment of 'global' to symbol 'test_shade' failed: symbol not defined
```

The issue is that test_shade does not belong to liboslcomp, instead it belongs to libtestshade,
and ld.lld actually checks that and fails. The minimal fix is to remove test_shade from hidesymbols.map,
the slightly better way is to create a separate symbols map for libtestshade.

See also: https://bugs.gentoo.org/929091

Signed-off-by: Sv. Lockal <lockalsash@gmail.com>
lgritz pushed a commit to lgritz/OpenShadingLanguage that referenced this pull request Mar 20, 2026
When using Clang 18<->22 with ld.lld, build fails with:
```
clang++ -Wl,--version-script=.../hidesymbols.map -o lib/liboslcomp.so.1.13.7 ...
ld.lld: error: version script assignment of 'global' to symbol 'test_shade' failed: symbol not defined
```

The issue is that test_shade does not belong to liboslcomp, instead it belongs to libtestshade,
and ld.lld actually checks that and fails. The minimal fix is to remove test_shade from hidesymbols.map,
the slightly better way is to create a separate symbols map for libtestshade.

See also: https://bugs.gentoo.org/929091

Signed-off-by: Sv. Lockal <lockalsash@gmail.com>
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.

2 participants