Skip to content

Conversation

@guitargeek
Copy link
Contributor

@guitargeek guitargeek commented Jan 6, 2026

This follows up on 47caba5, also generalizing the function on Windows by dynamically finding libCore.dll (or Core.dll depending on the toolchain).

The goal is to avoid using TROOT::GetRootSys() in the implementation of this method, with the overarching goal of not having to rely on environment variables like ROOTSYS one day, which might not be set in some environments like the Python wheels.

I disclose that ChatGPT was used for this mechanical task of translating code that already existed for macOS and Linux to Windows.

@guitargeek guitargeek self-assigned this Jan 6, 2026
@guitargeek guitargeek requested a review from dpiparo as a code owner January 6, 2026 20:31
@guitargeek guitargeek requested a review from pcanal as a code owner January 6, 2026 20:31
@guitargeek guitargeek force-pushed the getlibdir_windows branch 2 times, most recently from 937a69a to 09d18ef Compare January 6, 2026 21:04
DWORD needed = 0;

HANDLE process = GetCurrentProcess();
if (EnumProcessModules(process, modules, sizeof(modules), &needed)) {
Copy link
Member

Choose a reason for hiding this comment

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

Should we handle and/or warn about the failure case (eg. if there are more than 1024 libraries or any other error)? Right now, it seems that in the failure case the return value is 'empty'.

for (unsigned int i = 0; i < count; ++i) {
wchar_t wpath[MAX_PATH];
DWORD len = GetModuleFileNameW(modules[i], wpath, MAX_PATH);
if (!len)
Copy link
Member

Choose a reason for hiding this comment

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

It is probably okay to ignore arbitrary library (for which the path is too long) ... but one of them might be libCore resulting in return an empty string. Can we do better and/or can we warn the user in the case libCore was not found?

This follows up on 47caba5, also generalizing the function on
Windows by dynamically finding `libCore.dll` (or `Core.dll` depending on
the toolchain).

The goal is to avoid using `TROOT::GetRootSys()` in the implementation
of this method, with the overarching goal of not having to rely on
environment variables like `ROOTSYS` one day, which might not be set in
some environments like the Python wheels.
@guitargeek guitargeek changed the title [core] Generalize TROOT::GetLibDir() also on Windows [core] Generalize TROOT::GetShardLibDir() also on Windows Jan 6, 2026
@github-actions
Copy link

github-actions bot commented Jan 7, 2026

Test Results

    22 files      22 suites   3d 17h 33m 53s ⏱️
 3 789 tests  3 789 ✅ 0 💤 0 ❌
80 292 runs  80 292 ✅ 0 💤 0 ❌

Results for commit 65fe1cd.

♻️ This comment has been updated with latest results.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants