Skip to content

Fix shermes Windows CC path splitting (#1994)#2089

Open
tangtaizong666 wants to merge 2 commits into
facebook:static_hfrom
tangtaizong666:fix-shermes-windows-path-separator
Open

Fix shermes Windows CC path splitting (#1994)#2089
tangtaizong666 wants to merge 2 commits into
facebook:static_hfrom
tangtaizong666:fix-shermes-windows-path-separator

Conversation

@tangtaizong666

Copy link
Copy Markdown

Summary:

  • Use the platform path-list separator for shermes CC include/library paths on Windows.
  • Split generated CC path lists with llvh::sys::EnvPathSeparator.
  • Add a Windows regression test for drive-letter paths in verbose native compilation output.

Test Plan:

  • cmake -U SHERMES_CC_INCLUDE_PATH -U SHERMES_CC_LIB_PATH -S work\hermes-git -B work\hermes-git\cmake-build-asan -G Ninja -DCMAKE_BUILD_TYPE=Debug -DHERMES_ENABLE_ADDRESS_SANITIZER=ON -DHERMES_ENABLE_NAPI=OFF -DHERMES_TEST_EXTRA_ARGS="--path C:/application/Git/usr/bin" -DCMAKE_MAKE_PROGRAM="C:\application\vs\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja\ninja.exe"
  • cmake --build work\hermes-git\cmake-build-asan --target check-shermes --parallel 4 with LIT_FILTER=windows-cc-path-separator

Fixes #1994

@meta-cla

meta-cla Bot commented Jun 25, 2026

Copy link
Copy Markdown

Hi @tangtaizong666!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla meta-cla Bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Jun 25, 2026

@lavenzg lavenzg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for making the PR. Left some comments here.

Comment thread tools/shermes/CMakeLists.txt Outdated
else()
set(SHERMES_CC_PATH_SEPARATOR ":")
endif()
string(CONCAT SHERMES_CC_INCLUDE_PATH_DEFAULT

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use JOIN instead.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done in 79a4ab3 — switched to list(JOIN ...). The include and lib paths are now built from *_ENTRIES lists joined with SHERMES_CC_PATH_SEPARATOR (; on a Windows host, : otherwise), instead of hardcoding : inside a string(CONCAT ...).

// RUN: (CC=cmd %shermes -v -o %t.exe %s || true) 2>&1 | %FileCheck %s

// CHECK: cmd.exe
// CHECK-NOT: {{(^| )-IC( |$)}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There is no guarantee that SHERMES_CC_INCLUDE_PATH and SHERMES_CC_LIB_PATH will point to C: drive right?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Right — fixed in 79a4ab3. The CHECK-NOT patterns no longer assume the C: drive: they match any drive letter (-I[A-Za-z], -L[A-Za-z], -Wl,-rpath [A-Za-z]) and also assert the colon-joined DRIVE:...:DRIVE: shape ({{[A-Za-z]:[^ ]*:[A-Za-z]:}}) is absent, so the test catches the regression regardless of which drive the build tree lives on.

*/

// REQUIRES: windows
// RUN: (CC=cmd %shermes -v -o %t.exe %s || true) 2>&1 | %FileCheck %s

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I understand that we don't really need to compile the file, just use it to print out the include/lib paths. But it's still weird to pass cmd to CC. Could we just pass a fake flag here so that we can still get the full failed command and do check on the paths?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Switched to a fake flag in 79a4ab3: -Wc,--shermes-invalid-cc-option is forwarded to CC, which fails, so we still get the full failed CC invocation to FileCheck against (// CHECK: --shermes-invalid-cc-option) while no longer overriding CC=cmd.

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

Labels

CLA Signed Do not delete this pull request or issue due to inactivity.

2 participants