Skip to content

Conversation

@sbwtw
Copy link
Contributor

@sbwtw sbwtw commented Jan 4, 2026

fix wrong compiler param -mindirect-branch-register on MSVC

Copy link
Contributor

@lum1n0us lum1n0us left a comment

Choose a reason for hiding this comment

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

The -mndirect-branch-register is a Clang-specific option. I would suggest a shorter form like the one below.

if (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang")
  set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")
endif ()

It seems we should reduce the repetition of this code segment. I suggest moving this piece of code(the optimized version) to config_common.cmake. I haven't tested this idea before, so please let me know if it doesn't work if you decide to give it a try.

@sbwtw
Copy link
Contributor Author

sbwtw commented Jan 4, 2026

The -mndirect-branch-register is a Clang-specific option. I would suggest a shorter form like the one below.

if (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang")
  set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")
endif ()

It seems we should reduce the repetition of this code segment. I suggest moving this piece of code(the optimized version) to config_common.cmake. I haven't tested this idea before, so please let me know if it doesn't work if you decide to give it a try.

I moved these codes to config_common, and i found clang doesn't support -mindirect-branch-register. it's gcc only.

@lum1n0us
Copy link
Contributor

lum1n0us commented Jan 5, 2026

it's gcc only.

You are right. My mistaken.

@sbwtw
Copy link
Contributor Author

sbwtw commented Jan 6, 2026

Hi @lum1n0us , Thanks for your review. and I resolved all issues. please have a look

@sbwtw sbwtw requested a review from lum1n0us January 6, 2026 10:33
@sbwtw sbwtw requested a review from lum1n0us January 6, 2026 15:18
Copy link
Contributor

@lum1n0us lum1n0us left a comment

Choose a reason for hiding this comment

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

LGTM

@lum1n0us lum1n0us merged commit 3c337dc into bytecodealliance:main Jan 8, 2026
492 of 498 checks passed
@lum1n0us lum1n0us added the bug-fix Determine if this PR addresses a bug. It will be used by scripts to classify PRs. label Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix Determine if this PR addresses a bug. It will be used by scripts to classify PRs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants