Skip to content

Commit

Permalink
fix(ci): fix GCC Windows build
Browse files Browse the repository at this point in the history
When compiling with GCC on Windows hosts, 'g++ -Wl,--version' started
failing recently (past 2 weeks).

Observations:

* The problem only happens when using 'shell: bash', not the default
  shell for GitHub Actions.
* The problem seems to be related to $PATH and DLL lookup.
* There are two identical ld.exe files. One works fine; the other exits
  with no output when run from Bash.

Work around the problem by using 'shell: python' instead. (It's hard to
make the default shell work for Windows and non-Windows. Python is
consistent across hosts.)
  • Loading branch information
strager committed Feb 11, 2024
1 parent 434d085 commit c2ae70d
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 6 deletions.
37 changes: 34 additions & 3 deletions .github/workflows/build-and-test-plugin-vscode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,41 @@ jobs:
cmake --build build-tools --config Debug --target quick-lint-js-build-tools
- name: C++ configure
shell: "python3 {0}"
run: |
env | grep '^CMAKE\|^QUICK_LINT_JS' | sort
cmake ${CMAKE_C_COMPILER:+-DCMAKE_C_COMPILER="${CMAKE_C_COMPILER}"} ${CMAKE_CXX_COMPILER:+-DCMAKE_CXX_COMPILER="${CMAKE_CXX_COMPILER}"} -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=NO -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS}" -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}" -DCMAKE_EXE_LINKER_FLAGS="${CMAKE_EXE_LINKER_FLAGS}" -DCMAKE_SHARED_LINKER_FLAGS="${CMAKE_SHARED_LINKER_FLAGS}" -DQUICK_LINT_JS_ENABLE_VSCODE=YES -DCMAKE_POSITION_INDEPENDENT_CODE=YES -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=YES ${{ fromJSON('["", "-DQUICK_LINT_JS_USE_BUILD_TOOLS=${PWD}/build-tools"]')[matrix.os.cross_compiling] }} ${CMAKE_EXTRA_FLAGS} -S . -B build
shell: bash
import os
import shlex
import subprocess
import sys
def var(name):
return os.environ.get(name, '')
command = [
"cmake",
"-DCMAKE_BUILD_TYPE=Release",
"-DBUILD_TESTING=NO",
"-DQUICK_LINT_JS_ENABLE_VSCODE=YES",
"-DCMAKE_POSITION_INDEPENDENT_CODE=YES",
"-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=YES",
"-S", ".", "-B", "build",
f"-DCMAKE_C_FLAGS={var('CMAKE_C_FLAGS')}",
f"-DCMAKE_CXX_FLAGS={var('CMAKE_CXX_FLAGS')}",
f"-DCMAKE_EXE_LINKER_FLAGS={var('CMAKE_EXE_LINKER_FLAGS')}",
f"-DCMAKE_SHARED_LINKER_FLAGS={var('CMAKE_SHARED_LINKER_FLAGS')}",
]
c_compiler = var('CMAKE_C_COMPILER')
if c_compiler: command.append(f"-DCMAKE_C_COMPILER={c_compiler}")
cxx_compiler = var('CMAKE_CXX_COMPILER')
if cxx_compiler: command.append(f"-DCMAKE_CXX_COMPILER={cxx_compiler}")
if "${{ matrix.toolchain.cross_compiling }}":
commands.extend(f"-DQUICK_LINT_JS_USE_BUILD_TOOLS={os.getcwd()}/build-tools")
command.extend(var('CMAKE_EXTRA_FLAGS').split())
print(" ".join(shlex.quote(arg) for arg in command), file=sys.stderr)
result = subprocess.run(command)
exit(result.returncode)
- name: C++ build
run: cmake --build build --config Release --target quick-lint-js-vscode-node quick-lint-js-vscode-node-licenses
- name: C++ install
Expand Down
35 changes: 32 additions & 3 deletions .github/workflows/build-static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,39 @@ jobs:
cmake --build build-tools --config Debug --target quick-lint-js-build-tools
- name: configure
shell: "python3 {0}"
run: |
env | grep '^CMAKE\|^QUICK_LINT_JS' | sort
cmake ${CMAKE_C_COMPILER:+-DCMAKE_C_COMPILER="${CMAKE_C_COMPILER}"} ${CMAKE_CXX_COMPILER:+-DCMAKE_CXX_COMPILER="${CMAKE_CXX_COMPILER}"} -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=${{ matrix.toolchain.test }} -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=YES -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS}" -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}" -DCMAKE_EXE_LINKER_FLAGS="${CMAKE_EXE_LINKER_FLAGS}" -DCMAKE_SHARED_LINKER_FLAGS="${CMAKE_SHARED_LINKER_FLAGS}" ${{ fromJSON('["", "-DQUICK_LINT_JS_USE_BUILD_TOOLS=${PWD}/build-tools"]')[matrix.toolchain.cross_compiling] }} ${CMAKE_EXTRA_FLAGS} -S . -B build
shell: bash
import os
import shlex
import subprocess
import sys
def var(name):
return os.environ.get(name, '')
command = [
"cmake",
"-DCMAKE_BUILD_TYPE=Release",
"-DBUILD_TESTING=${{ matrix.toolchain.test }}",
"-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=YES",
"-S", ".", "-B", "build",
f"-DCMAKE_C_FLAGS={var('CMAKE_C_FLAGS')}",
f"-DCMAKE_CXX_FLAGS={var('CMAKE_CXX_FLAGS')}",
f"-DCMAKE_EXE_LINKER_FLAGS={var('CMAKE_EXE_LINKER_FLAGS')}",
f"-DCMAKE_SHARED_LINKER_FLAGS={var('CMAKE_SHARED_LINKER_FLAGS')}",
]
c_compiler = var('CMAKE_C_COMPILER')
if c_compiler: command.append(f"-DCMAKE_C_COMPILER={c_compiler}")
cxx_compiler = var('CMAKE_CXX_COMPILER')
if cxx_compiler: command.append(f"-DCMAKE_CXX_COMPILER={cxx_compiler}")
if "${{ matrix.toolchain.cross_compiling }}":
commands.extend(f"-DQUICK_LINT_JS_USE_BUILD_TOOLS={os.getcwd()}/build-tools")
command.extend(var('CMAKE_EXTRA_FLAGS').split())
print(" ".join(shlex.quote(arg) for arg in command), file=sys.stderr)
result = subprocess.run(command)
exit(result.returncode)
- name: build
run: cmake --build build --config Release
- name: test
Expand Down

0 comments on commit c2ae70d

Please sign in to comment.