Skip to content

FIx compilation on Windows with GCC16#3386

Merged
Lestropie merged 1 commit into
devfrom
tractography_compilation_windows
Jun 4, 2026
Merged

FIx compilation on Windows with GCC16#3386
Lestropie merged 1 commit into
devfrom
tractography_compilation_windows

Conversation

@Lestropie
Copy link
Copy Markdown
Member

The failure to generate the DLL due to mismatched compiler used for the GPU Dawn library in #3384 was obscuring a second linking failure due to the same TLS change in GCC16. This is I think the least obtrusive fix.

Replace the namespace-scope thread-local MR::DWI::Tractography::rng with a
function-local thread_local accessed via a rng() accessor, lazily constructed
on first use. The previous extern thread_local definition triggered
compilation failures under GCC 16 on Windows due to changes in thread-local
storage handling; the Meyers idiom sidesteps that codepath while preserving
identical per-thread semantics. All call sites across the seeding, algorithm,
and tracking code were updated to invoke rng() accordingly.

Session prompts:
1. > Implement a Meyers-style accessor function for variable
   > MR::DWI::Tractography::rng, to prevent compilation failures on Windows
   > due to TLS changes in GCC16.

Generated-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

There were too many comments to post at once. Showing the first 25 out of 41. Check the log or trigger a new build to see more.

}

if (uniform(rng) < val / max_val) {
if (uniform(rng()) < val / max_val) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

warning: no header providing "MR::DWI::Tractography::rng" is directly included [misc-include-cleaner]

cpp/core/dwi/tractography/algorithms/iFOD1.h:23:

- #include "dwi/tractography/tracking/method.h"
+ #include "dwi/tractography/rng.h"
+ #include "dwi/tractography/tracking/method.h"

}

if (uniform(rng) < val / max_val) {
if (uniform(rng()) < val / max_val) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

warning: no header providing "MR::DWI::Tractography::rng" is directly included [misc-include-cleaner]

cpp/core/dwi/tractography/algorithms/iFOD2.h:25:

- #include "dwi/tractography/tracking/method.h"
+ #include "dwi/tractography/rng.h"
+ #include "dwi/tractography/tracking/method.h"

}

float get_metric(const Eigen::Vector3f &, const Eigen::Vector3f &) override { return uniform(rng); }
float get_metric(const Eigen::Vector3f &, const Eigen::Vector3f &) override { return uniform(rng()); }
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

warning: all parameters should be named in a function [readability-named-parameter]

Suggested change
float get_metric(const Eigen::Vector3f &, const Eigen::Vector3f &) override { return uniform(rng()); }
float get_metric(const Eigen::Vector3f & /*position*/, const Eigen::Vector3f & /*direction*/) override { return uniform(rng()); }

}

float get_metric(const Eigen::Vector3f &, const Eigen::Vector3f &) override { return uniform(rng); }
float get_metric(const Eigen::Vector3f &, const Eigen::Vector3f &) override { return uniform(rng()); }
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

warning: no header providing "MR::DWI::Tractography::rng" is directly included [misc-include-cleaner]

cpp/core/dwi/tractography/algorithms/nulldist.h:22:

- #include "dwi/tractography/tracking/method.h"
+ #include "dwi/tractography/rng.h"
+ #include "dwi/tractography/tracking/method.h"

}

float get_metric(const Eigen::Vector3f &, const Eigen::Vector3f &) override { return uniform(rng); }
float get_metric(const Eigen::Vector3f &, const Eigen::Vector3f &) override { return uniform(rng()); }
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

warning: all parameters should be named in a function [readability-named-parameter]

Suggested change
float get_metric(const Eigen::Vector3f &, const Eigen::Vector3f &) override { return uniform(rng()); }
float get_metric(const Eigen::Vector3f & /*position*/, const Eigen::Vector3f & /*direction*/) override { return uniform(rng()); }

} while (seed.value() < selector);
p = {seed.index(0) + uniform(rng) - 0.5f, seed.index(1) + uniform(rng) - 0.5f, seed.index(2) + uniform(rng) - 0.5f};
p = {seed.index(0) + uniform(rng()) - 0.5f,
seed.index(1) + uniform(rng()) - 0.5f,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

warning: floating point literal has suffix 'f', which is not uppercase [readability-uppercase-literal-suffix]

Suggested change
seed.index(1) + uniform(rng()) - 0.5f,
seed.index(1) + uniform(rng()) - 0.5F,

} while (seed.value() < selector);
p = {seed.index(0) + uniform(rng) - 0.5f, seed.index(1) + uniform(rng) - 0.5f, seed.index(2) + uniform(rng) - 0.5f};
p = {seed.index(0) + uniform(rng()) - 0.5f,
seed.index(1) + uniform(rng()) - 0.5f,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

warning: narrowing conversion from 'ssize_t' (aka 'long') to 'result_type' (aka 'float') [bugprone-narrowing-conversions]

       seed.index(1) + uniform(rng()) - 0.5f,
       ^

p = {seed.index(0) + uniform(rng) - 0.5f, seed.index(1) + uniform(rng) - 0.5f, seed.index(2) + uniform(rng) - 0.5f};
p = {seed.index(0) + uniform(rng()) - 0.5f,
seed.index(1) + uniform(rng()) - 0.5f,
seed.index(2) + uniform(rng()) - 0.5f};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

warning: floating point literal has suffix 'f', which is not uppercase [readability-uppercase-literal-suffix]

Suggested change
seed.index(2) + uniform(rng()) - 0.5f};
seed.index(2) + uniform(rng()) - 0.5F};

p = {seed.index(0) + uniform(rng) - 0.5f, seed.index(1) + uniform(rng) - 0.5f, seed.index(2) + uniform(rng) - 0.5f};
p = {seed.index(0) + uniform(rng()) - 0.5f,
seed.index(1) + uniform(rng()) - 0.5f,
seed.index(2) + uniform(rng()) - 0.5f};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

warning: narrowing conversion from 'ssize_t' (aka 'long') to 'result_type' (aka 'float') [bugprone-narrowing-conversions]

       seed.index(2) + uniform(rng()) - 0.5f};
       ^

const Eigen::Vector3i &v(fixel.get_voxel());
const Eigen::Vector3f vp(
v[0] + uniform_float(rng) - 0.5, v[1] + uniform_float(rng) - 0.5, v[2] + uniform_float(rng) - 0.5);
v[0] + uniform_float(rng()) - 0.5, v[1] + uniform_float(rng()) - 0.5, v[2] + uniform_float(rng()) - 0.5);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

warning: narrowing conversion from 'double' to 'Scalar' (aka 'float') [bugprone-narrowing-conversions]

          v[0] + uniform_float(rng()) - 0.5, v[1] + uniform_float(rng()) - 0.5, v[2] + uniform_float(rng()) - 0.5);
                                                                                ^

@Lestropie Lestropie merged commit 4987e73 into dev Jun 4, 2026
5 of 7 checks passed
@Lestropie Lestropie deleted the tractography_compilation_windows branch June 4, 2026 02:18
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.

1 participant