Skip to content

#2328: Use Starlark rules#2429

Merged
mergify[bot] merged 22 commits into
masterfrom
axman6/2328-use-starlark-rules
Jun 9, 2026
Merged

#2328: Use Starlark rules#2429
mergify[bot] merged 22 commits into
masterfrom
axman6/2328-use-starlark-rules

Conversation

@axman6

@axman6 axman6 commented May 22, 2026

Copy link
Copy Markdown
Contributor

An attempt to fix #2328, which removes the use of the native rules_cc, rules_java and protobuf rules. bazel build [--enable_bzlmod] //... and bazel build [--enable_bzlmod] //... all build and pass on my machine so hopefully this has actually worked...

Updates deps:

  • rules_cc: 0.0.9 -> 0.0.17 (latest 0.0.X version)
  • rules_java: 6.1.0 -> 6.5.2 (latest 6.X.Y version)
  • protobuf: 21.7 -> 28.3 (matching haskell/repositories.bzl)

Each commit should probably be reviewed separately, most changes were from buildifier, with the final commit implementing some optional changes suggested by the LSP including documenting some undocumented arguments as far as I could understand them.

@axman6 axman6 requested a review from avdv as a code owner May 22, 2026 08:27
@axman6 axman6 force-pushed the axman6/2328-use-starlark-rules branch from 97c351e to 0ea4978 Compare May 22, 2026 08:31
@axman6

axman6 commented May 22, 2026

Copy link
Copy Markdown
Contributor Author

Looks like this is broken in CI, and I don't have a clue where to begin to fix it. I'll take another look on Monday.

@avdv

avdv commented May 22, 2026

Copy link
Copy Markdown
Member

Thank you, that looks quite good.

It just seems there is a problem with running the example and the start script regarding rules_java.

This is because you only added rules_java to the WORKSPACE file for rules_haskell, which only has an effect on this project (all tests are green for rules_haskell) but does not have any effect on other workspaces (such as the example or in the project created by the start script).

You should add a similar maybe(http_archive, ...) call for rules_java to haskell/repositories.bzl like the one for rules_cc (an exception to this are dev dependencies that are only used during development). Any setup calls (like rules_java_dependencies) need to be added to every WORKSPACE file separately, including the start script which generates a WORKSPACE file.

BTW, usually we try to be quite conservative with module updates in MODULE.bazel files for the main module and only bump bazel_deps in the test module. Due to the MVS algorithm we ensure that things work for newer versions but don't force anyone else using rules_haskell to use the latest version of our dependencies. This is in contrast to WORKSPACE mode where one is free to use a different version whatsoever. See https://github.com/tweag/renovate-presets#why-are-updates-to-the-root-modulebazel-ignored for the rationale.

Having said that, if things work with the current version bumps, let's keep them this way as Bazel 6 is EOL already and we really ought to move on to Bazel 7 and 8...

One thing that failed after the version bump of protobuf is the Windows compilation, see https://github.com/tweag/rules_haskell/actions/runs/26277294428/job/77344953463?pr=2429 -- so that should probably be reverted.

@axman6

axman6 commented May 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @avdv, that makes a lot of sense, I'll see if I can get things working.

@avdv

avdv commented May 27, 2026

Copy link
Copy Markdown
Member

That looks much better now, only a few failing jobs left...

All the failing jobs use bzlmod (the true of the matrix values in parens). And one of them is just failing due to a network problem.

One error looks familiar to me:

ERROR: /Users/runner/work/rules_haskell/rules_haskell/rules_haskell_tests/tests/template-haskell-with-cbits/BUILD.bazel:8:13: HaskellBuildBinary @@//tests/template-haskell-with-cbits:template-haskell-with-cbits failed: (Exit 1): ghc_wrapper failed: error executing command (from target //tests/template-haskell-with-cbits:template-haskell-with-cbits) 
  (cd /private/var/tmp/_bazel_runner/6f93c0710d32c05eb86fd5414239ece6/sandbox/darwin-sandbox/2328/execroot/_main && \
  exec env - \
    CC_WRAPPER_CC_PATH=external/rules_cc~0.0.17~cc_configure_extension~local_config_cc/cc_wrapper.sh \
    CC_WRAPPER_CPU=darwin_arm64 \
    CC_WRAPPER_PLATFORM=darwin \
    LANG=en_US.UTF-8 \
    MUST_EXTRACT_ABI=false \
    PATH=/usr/bin:/bin:/usr/sbin \
    RULES_HASKELL_DOCDIR_PATH=external/rules_haskell~1.0~haskell_toolchains~rules_haskell_ghc_darwin_arm64/doc/html/libraries/base-4.17.2.1 \
    RULES_HASKELL_GHC_PATH=external/rules_haskell~1.0~haskell_toolchains~rules_haskell_ghc_darwin_arm64/bin/ghc \
    RULES_HASKELL_GHC_PKG_PATH=external/rules_haskell~1.0~haskell_toolchains~rules_haskell_ghc_darwin_arm64/bin/ghc-pkg \
    RULES_HASKELL_LIBDIR_PATH=external/rules_haskell~1.0~haskell_toolchains~rules_haskell_ghc_darwin_arm64/lib/lib \
  bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/rules_haskell~1.0/haskell/ghc_wrapper bazel-out/darwin_arm64-fastbuild/bin/tests/template-haskell-with-cbits/compile_flags_template-haskell-with-cbits__HaskellBuildBinary bazel-out/darwin_arm64-fastbuild/bin/tests/template-haskell-with-cbits/extra_args_template-haskell-with-cbits__HaskellBuildBinary)
# Configuration: 6fba1e142be9e8f591a45ad5b96a2a5e25dc5171c380642d9d848e8e37c652a0
# Execution platform: @local_config_platform//:host

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
ld: warning: -single_module is obsolete
ld: warning: object file (/private/var/tmp/_bazel_runner/6f93c0710d32c05eb86fd5414239ece6/sandbox/darwin-sandbox/2328/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/tests/template-haskell-with-cbits/_obj/template-haskell-with-cbits/TH.dyn_o) was built for newer 'macOS' version (14.5) than being linked (14.0)
/var/folders/y8/mxm23y3s6m38f6r8d1pbqz600000gn/T/ghc39858_0/libghc_5.dylib.resign: replacing existing signature

<no location info>: error:
    
GHC.Linker.Loader.dynLoadObjs: Loading temp shared object failed
During interactive linking, GHCi couldn't find the following symbol:
  dlopen(/var/folders/y8/mxm23y3s6m38f6r8d1pbqz600000gn/T/ghc39858_0/libghc_5.dylib, 0x0005): symbol not found in flat namespace '_c_add_one'

https://github.com/tweag/rules_haskell/actions/runs/26503196184/job/78048731156#step:10:1466

It is the same error we see when trying to upgrade rules_cc to version 0.2.0 in this PR (job: https://github.com/tweag/rules_haskell/actions/runs/23786889871/job/69312225140)

Is bumping the rules_cc module really necessary? Maybe it works with lower versions... However, if we can fix the problem, that would be even better.

@avdv avdv force-pushed the axman6/2328-use-starlark-rules branch 2 times, most recently from 20795fb to b9a1411 Compare May 29, 2026 14:55
@avdv

avdv commented May 29, 2026

Copy link
Copy Markdown
Member

FYI, I tried rules_cc 0.0.15 because it seemed to work on my machine, but actually was not the case.

@axman6 axman6 force-pushed the axman6/2328-use-starlark-rules branch 2 times, most recently from 3745a09 to 21b7669 Compare June 5, 2026 05:30
@avdv avdv force-pushed the axman6/2328-use-starlark-rules branch 2 times, most recently from 7567617 to cb5d04f Compare June 5, 2026 13:48
@avdv

avdv commented Jun 5, 2026

Copy link
Copy Markdown
Member

Unfortunately, it still did not work even with rules_cc version 0.1.1.

I took a deeper look and compared the cc toolchain of the old and new versions and I realized that the problem is the same we saw after upgrading Bazel -- the rules_cc toolchain does no longer produce shared libraries on macOS for cc_library targets. But the failing test depends on a shared library to work...

So, I added a cc_shared_library explicitly and this resolves the problem. 🎉

There are now these issues left:

  1. windows fails to build protoc (https://github.com/tweag/rules_haskell/actions/runs/27021294459/job/79749618182)
  2. on windows, fails with lld: error: unable to find library -lHSexternalZSZUmainz7eUnonZUmoduleZUdepsz7eUlibraryZUrepoZSTestLib (https://github.com/tweag/rules_haskell/actions/runs/27021294459/job/79749618151)
  3. on macOS fails to build the example with bzlmod enabled using nixpkgs (https://github.com/tweag/rules_haskell/actions/runs/27021294459/job/79749618004)

For 1) I already added a patch to protoc which we also applied to rules_haskell_test. But it seems that's not enough. \edit: I upgraded abseil-cpp and that fixed it.

For 3), this seems to be caused by using a nixpkgs based C/C++ compiler which does not work when the nix specific variables are not set (e.g. inside of isolated build actions). It seems the example does not register a nixpkgs based cc toolchain for bzlmod. \edit: adding a nixpkgs based cc toolchain fixed this

@avdv avdv force-pushed the axman6/2328-use-starlark-rules branch 3 times, most recently from e1d9f12 to 2dba7fd Compare June 8, 2026 21:32
@avdv

avdv commented Jun 9, 2026

Copy link
Copy Markdown
Member

Some debugging output:

# "bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/rules_haskell~1.0/haskell/cc_wrapper-bash.exe" "-fstack-check" "-o" "bazel-out/x64_windows-fastbuild/bin/tests/library-external-workspace/bin-deps.exe" "-lm" "-no-pie" "-Wl,--enable-auto-import" "-Wl,--gc-sections" "bazel-out\x64_windows-fastbuild\bin\tests\library-external-workspace\_obj\bin-deps\Main.o" "C:\msys64\tmp\ghc716_0\ghc_5.o" "-Lbazel-out/x64_windows-fastbuild/bin/tests/library-external-workspace/" "-Lbazel-out/x64_windows-fastbuild/bin/tests/library-external-workspace/../../external/_main~non_module_deps~library_repo/" "-LC:\_bzl\33jjwvv5\external\rules_haskell~1.0~haskell_toolchains~bindist_rules_haskell_tests_1.0_windows_amd64\lib\x86_64-windows-ghc-9.4.8\base-4.17.2.1" "-LC:\_bzl\33jjwvv5\external\rules_haskell~1.0~haskell_toolchains~bindist_rules_haskell_tests_1.0_windows_amd64\lib\x86_64-windows-ghc-9.4.8\ghc-bignum-1.3" "-LC:\_bzl\33jjwvv5\external\rules_haskell~1.0~haskell_toolchains~bindist_rules_haskell_tests_1.0_windows_amd64\lib\x86_64-windows-ghc-9.4.8\ghc-prim-0.9.1" "-LC:\_bzl\33jjwvv5\external\rules_haskell~1.0~haskell_toolchains~bindist_rules_haskell_tests_1.0_windows_amd64\lib\x86_64-windows-ghc-9.4.8\rts-1.0.2" "C:\msys64\tmp\ghc716_0\ghc_2.o" "-Wl,-u,hs_atomic_add64" "-Wl,-u,hs_atomic_sub64" "-Wl,-u,hs_atomic_and64" "-Wl,-u,hs_atomic_nand64" "-Wl,-u,hs_atomic_or64" "-Wl,-u,hs_atomic_xor64" "-Wl,-u,hs_atomicread64" "-Wl,-u,hs_atomicwrite64" "-Wl,-u,base_GHCziTopHandler_runIO_closure" "-Wl,-u,ba
se_GHCziTopHandler_runNonIO_closure" "-Wl,-u,ghczmprim_GHCziTuple_Z0T_closure" "-Wl,-u,ghczmprim_GHCziTypes_True_closure" "-Wl,-u,ghczmprim_GHCziTypes_False_closure" "-Wl,-u,base_GHCziPack
_unpackCString_closure" "-Wl,-u,base_GHCziWeak_runFinalizzerBatch_closure" "-Wl,-u,base_GHCziIOziException_stackOverflow_closure" "-Wl,-u,base_GHCziIOziException_heapOverflow_closure" "-Wl
,-u,base_GHCziIOziException_allocationLimitExceeded_closure" "-Wl,-u,base_GHCziIOziException_blockedIndefinitelyOnMVar_closure" "-Wl,-u,base_GHCziIOziException_blockedIndefinitelyOnSTM_clo
sure" "-Wl,-u,base_GHCziIOziException_cannotCompactFunction_closure" "-Wl,-u,base_GHCziIOziException_cannotCompactPinned_closure" "-Wl,-u,base_GHCziIOziException_cannotCompactMutable_closu
re" "-Wl,-u,base_GHCziIOPort_doubleReadException_closure" "-Wl,-u,base_ControlziExceptionziBase_nonTermination_closure" "-Wl,-u,base_ControlziExceptionziBase_nestedAtomically_closure" "-Wl,-u,base_GHCziEventziThread_blockedOnBadFD_closure" "-Wl,-u,base_GHCziConcziSync_runSparks_closure" "-Wl,-u,base_GHCziConcziIO_ensureIOManagerIsRunning_closure" "-Wl,-u,base_GHCziConcziIO_interruptIOManager_closure" "-Wl,-u,base_GHCziConcziIO_ioManagerCapabilitiesChanged_closure" "-Wl,-u,base_GHCziConcziSignal_runHandlersPtr_closure" "-Wl,-u,base_GHCziTopHandler_flushStdHandles_closure" "-Wl,-u,base_GHCziTopHandler_runMainIO_closure" "-Wl,-u,ghczmprim_GHCziTypes_Czh_con_info" "-Wl,-u,ghczmprim_GHCziTypes_Izh_con_info" "-Wl,-u,ghczmprim_GHCziTypes_Fzh_con_info" "-Wl,-u,ghczmprim_GHCziTypes_Dzh_con_info" "-Wl,-u,ghczmprim_GHCziTypes_Wzh_con_info" "-Wl,-u,base_GHCziPtr_Ptr_con_info" "-Wl,-u,base_GHCziPtr_FunPtr_con_info" "-Wl,-u,base_GHCziInt_I8zh_con_info" "-Wl,-u,base_GHCziInt_I16zh_con_info" "-Wl,-u,base_GHCziInt_I32zh_con_info" "-Wl,-u,base_GHCziInt_I64zh_con_info" "-Wl,-u,base_GHCziWord_W8zh_con_info" "-Wl,-u,base_GHCziWord_W16zh_con_info" "-Wl,-u,base_GHCziWord_W32zh_con_info" "-Wl,-u,base_GHCziWord_W64zh_con_info" "-Wl,-u,base_GHCziStable_StablePtr_con_info" "-Wl,-u,hs_atomic_add8" "-Wl,-u,hs_atomic_add16" "-Wl,-u,hs_atomic_add32" "-Wl,-u,hs_atomic_sub8" "-Wl,-u,hs_atomic_sub16" "-Wl,-u,hs_atomic_sub32" "-Wl,-u,hs_atomic_and8" "-Wl,-u,hs_atomic_and16" "-Wl,-u,hs_atomic_and32" "-Wl,-u,hs_atomic_nand8" "-Wl,-u,hs_atomic_nand16" "-Wl,-u,hs_atomic_nand32" "-Wl,-u,hs_atomic_or8" "-Wl,-u,hs_atomic_or16" "-Wl,-u,hs_atomic_or32" "-Wl,-u,hs_atomic_xor8" "-Wl,-u,hs_atomic_xor16" "-Wl,-u,hs_atomic_xor32" "-Wl,-u,hs_cmpxchg8" "-Wl,-u,hs_cmpxchg16" "-Wl,-u,hs_cmpxchg32" "-Wl,-u,hs_cmpxchg64" "-Wl,-u,hs_xchg8" "-Wl,-u,hs_xchg16" "-Wl,-u,hs_xchg32" "-Wl,-u,hs_xchg64" "-Wl,-u
,hs_atomicread8" "-Wl,-u,hs_atomicread16" "-Wl,-u,hs_atomicread32" "-Wl,-u,hs_atomicwrite8" "-Wl,-u,hs_atomicwrite16" "-Wl,-u,hs_atomicwrite32" "-Wl,-u,base_GHCziStackziCloneStack_StackSna
pshot_closure" "-Wl,-u,base_GHCziEventziWindows_processRemoteCompletion_closure" "-lHStestsZSlibrary-external-workspaceZSTestLib" "-lHSexternalZSZUmainz7eUnonZUmoduleZUdepsz7eUlibraryZUrep
oZSTestLib" "-lHSbase-4.17.2.1" "-lHSghc-bignum-1.3" "-lHSghc-prim-0.9.1" "-lHSrts-1.0.2_thr" "-lCffi-6" "-lwsock32" "-luser32" "-lshell32" "-lmingw32" "-lkernel32" "-ladvapi32" "-lmingwex
" "-lws2_32" "-lshlwapi" "-lole32" "-lrpcrt4" "-lntdll" "-luser32" "-lmingw32" "-lmingwex" "-lucrt" "-lm" "-lwsock32" "-lgdi32" "-lwinmm" "-ldbghelp" "-lpsapi" "-lpthread" "-lstdc++" "-Wl,
-verbose" "-pthread" "-Wno-unused-command-line-argument" -v
clang version 14.0.6
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: C:/_bzl/33jjwvv5/execroot/_main/external/rules_haskell~1.0~haskell_toolchains~rules_haskell_ghc_windows_amd64/mingw/bin
 "C:/_bzl/33jjwvv5/execroot/_main/external/rules_haskell~1.0~haskell_toolchains~rules_haskell_ghc_windows_amd64/mingw/bin/ld.lld" -m i386pep -Bdynamic -o bazel-out/x64_windows-fastbuild/bin/tests/library-external-workspace/bin-deps.exe C:/_bzl/33jjwvv5/execroot/_main/external/rules_haskell~1.0~haskell_toolchains~rules_haskell_ghc_windows_amd64/mingw/x86_64-w64-mingw32/lib/crt2.o C:/_bzl/33jjwvv5/execroot/_main/external/rules_haskell~1.0~haskell_toolchains~rules_haskell_ghc_windows_amd64/mingw/x86_64-w64-mingw32/lib/crtbegin.o -Lbazel-out/x64_windows-fastbuild/bin/tests/library-external-workspace/ -L/c/_bzl/33jjwvv5/execroot/_main/bazel-out/x64_windows-fastbuild/bin/external/_main~non_module_deps~library_repo -L../../external/rules_haskell~1.0~haskell_toolchains~bindist_rules_haskell_tests_1.0_windows_amd64/lib/x86_64-windows-ghc-9.4.8/base-4.17.2.1 -L../../external/rules_haskell~1.0~haskell_toolchains~bindist_rules_haskell_tests_1.0_windows_amd64/lib/x86_64-windows-ghc-9.4.8/ghc-bignum-1.3 -L../../external/rules_haskell~1.0~haskell_toolchains~bindist_rules_haskell_tests_1.0_windows_amd64/lib/x86_64-windows-ghc-9.4.8/ghc-prim-0.9.1 -L../../external/rules_haskell~1.0~haskell_toolchains~bindist_rules_haskell_tests_1.0_windows_amd64/lib/x86_64-windows-ghc-9.4.8/rts-1.0.2 -LC:/_bzl/33jjwvv5/execroot/_main/external/rules_haskell~1.0~haskell_toolchains~rules_haskell_ghc_windows_amd64/mingw/x86_64-w64-mingw32/lib -LC:/_bzl/33jjwvv5/execroot/_main/external/rules_haskell~1.0~haskell_toolchains~rules_haskell_ghc_windows_amd64/mingw/lib -LC:/_bzl/33jjwvv5/execroot/_main/external/rules_haskell~1.0~haskell_toolchains~rules_haskell_ghc_windows_amd64/mingw/x86_64-w64-mingw32/sys-
root/mingw/lib -LC:/_bzl/33jjwvv5/execroot/_main/external/rules_haskell~1.0~haskell_toolchains~rules_haskell_ghc_windows_amd64/mingw/lib/clang/14.0.6/lib/windows -lm --enable-auto-import -
-gc-sections "bazel-out\\x64_windows-fastbuild\\bin\\tests\\library-external-workspace\\_obj\\bin-deps\\Main.o" "C:\\msys64\\tmp\\ghc716_0\\ghc_5.o" "C:\\msys64\\tmp\\ghc716_0\\ghc_2.o" -u
 hs_atomic_add64 -u hs_atomic_sub64 -u hs_atomic_and64 -u hs_atomic_nand64 -u hs_atomic_or64 -u hs_atomic_xor64 -u hs_atomicread64 -u hs_atomicwrite64 -u base_GHCziTopHandler_runIO_closure
 -u base_GHCziTopHandler_runNonIO_closure -u ghczmprim_GHCziTuple_Z0T_closure -u ghczmprim_GHCziTypes_True_closure -u ghczmprim_GHCziTypes_False_closure -u base_GHCziPack_unpackCString_closure -u base_GHCziWeak_runFinalizzerBatch_closure -u base_GHCziIOziException_stackOverflow_closure -u base_GHCziIOziException_heapOverflow_closure -u base_GHCziIOziException_allocationLimitExceeded_closure -u base_GHCziIOziException_blockedIndefinitelyOnMVar_closure -u base_GHCziIOziException_blockedIndefinitelyOnSTM_closure -u base_GHCziIOziException_cannotCompactFunction_closure -u base_GHCziIOziException_cannotCompactPinned_closure -u base_GHCziIOziException_cannotCompactMutable_closure -u base_GHCziIOPort_doubleReadException_closure -u base_ControlziExceptionziBase_nonTermination_closure -u base_ControlziExceptionziBase_nestedAtomically_closure -u base_GHCziEventziThread_blockedOnBadFD_closure -u base_GHCziConcziSync_runSparks_closure -u base_GHCziConcziIO_ensureIOManagerIsRunning_closure -u base_GHCziConcziIO_interruptIOManager_closure -u base_GHCziConcziIO_ioManagerCapabilitiesChanged_closure -u base_GHCziConcziSignal_runHandlersPtr_closure -u base_GHCziTopHandler_flushStdHandles_closure -u base_GHCziTopHandler_runMainIO_closure -u ghczmprim_GHCziTypes_Czh_con_info -u ghczmprim_GHCziTypes_Izh_con_info -u ghczmprim_GHCziTypes_Fzh_con_info -u ghczmprim_GHCziTypes_Dzh_con_info -u ghczmprim_GHCziTypes_Wzh_con_info -u base_GHCziPtr_Ptr_con_info -u base_GHCziPtr_FunPtr_con_info -u base_GHCziInt_I8zh_con_info -u base_GHCziInt_I16zh_con_info -u base_GHCziInt_I32zh_con_info -u base_GHCziInt_I64zh_con_info -u base_GHCziWord_W8zh_con_info -u base_GHCziWord_W16zh_con_info -u base_GHCziWord_W32zh_con_info -u base_GHCziWord_W64zh_con_info -u base_GHCziStable_StablePtr_con_info -u hs_atomic_add8 -u hs_atomic_add16 -u hs_atomic_add32 -u hs_atomic_sub8 -u hs_atomic_sub16 -u hs_atomic_sub32 -u hs_atomic_and8 -u hs_atomic_and16 -u hs_atomic_and32 -u hs_atomic_nand8 -u hs_atomic_nand16 -u hs_atomic_nand32 -u hs_atomic_or8 -u hs_atomic_or16 -u hs_atomic_or32 -u hs_atomic_xor8 -u hs_atomic_xor16 -u hs_atomic_xor32 -u hs_cmpxchg8 -u hs_cmpxchg16 -u hs_cmpxchg32 -u hs_cmpxchg64 -u hs_xchg8 -u hs_xchg16 -u hs_xchg32 -u hs_xchg64 -u hs_atomicread8 -u hs_atomicread16 -u hs_atomicread32 -u hs_atomicwrite8 -u hs_atomicwrite16 -u hs_atomicwrite32 -u base_GHCziStackziCloneStack_StackSnapshot_closure -u base_GHCziEventziWindows_processRemoteCompletion_closure -lHStestsZSlibrary-external-workspaceZSTestLib -lHSexternalZSZUmainz7eUnonZUmoduleZUdepsz7eUlibraryZUrepoZSTestLib -lHSbase-4.17.2.1 -lHSghc-bignum-1.3 -lHSghc-prim-0.9.1
 -lHSrts-1.0.2_thr -lCffi-6 -lwsock32 -luser32 -lshell32 -lmingw32 -lkernel32 -ladvapi32 -lmingwex -lws2_32 -lshlwapi -lole32 -lrpcrt4 -lntdll -luser32 -lmingw32 -lmingwex -lucrt -lm -lwso
ck32 -lgdi32 -lwinmm -ldbghelp -lpsapi -lpthread -lc++ -verbose -lmingw32 C:/_bzl/33jjwvv5/execroot/_main/external/rules_haskell~1.0~haskell_toolchains~rules_haskell_ghc_windows_amd64/ming
w/lib/clang/14.0.6/lib/windows/libclang_rt.builtins-x86_64.a -lunwind -lmoldname -lmingwex -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 C:/_bzl/33jjwvv5/execroot/_main/exte
rnal/rules_haskell~1.0~haskell_toolchains~rules_haskell_ghc_windows_amd64/mingw/lib/clang/14.0.6/lib/windows/libclang_rt.builtins-x86_64.a -lunwind -lmoldname -lmingwex -lkernel32 C:/_bzl/
33jjwvv5/execroot/_main/external/rules_haskell~1.0~haskell_toolchains~rules_haskell_ghc_windows_amd64/mingw/x86_64-w64-mingw32/lib/crtend.o
lld: error: unable to find library -lHSexternalZSZUmainz7eUnonZUmoduleZUdepsz7eUlibraryZUrepoZSTestLib
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Notice the "-Lbazel-out/x64_windows-fastbuild/bin/tests/library-external-workspace/../../external/_main~non_module_deps~library_repo/" argument, which gets translated to -L/c/_bzl/33jjwvv5/execroot/_main/bazel-out/x64_windows-fastbuild/bin/external/_main~non_module_deps~library_repo when passed to the linker. I am not sure the linker is able to understand the mingw path starting with /c/ instead of c:/.

After manually normalizing the argument to "-Lbazel-out/x64_windows-fastbuild/bin/external/_main~non_module_deps~library_repo/", it works (-Lbazel-out/x64_windows-fastbuild/bin/external/_main~non_module_deps~library_repo/ gets passed to the linker).

avdv added 10 commits June 9, 2026 12:43
The local cc toolchain created by the updated rules_cc module is different:

It does not support creating shared libraries on macOS anymore (the toolchain
is missing the `supports_dynamic_linker` feature).

Instead, we have to use a cc_shared_library explictly.

See bazelbuild/apple_support#326 (comment)
This is actually the oldest version that is compatible with Bazel 6 and
also provides cc_shared_library at the expected place.

But it also requires protobuf 27.0, which is broken on Windows using the
MinGW compiler. We have to add a patch (which only applies to this module)
in order to fix this.

Also, bump versions of modules which are newer in the dependency graph.
On Windows, we try to work around the path limit by normalizing paths. This stopped working
because $PWD was set to a Windows-style path (C:/...) instead of a MSYS-style one.

So, relativizing the shortened path did not work and the MSYS style path was handed to the
linker which did not understand it and could not find the libraries in there.
This repository is already instantiated by calling `rules_haskell_dependencies()`.
@avdv avdv force-pushed the axman6/2328-use-starlark-rules branch from 741240e to 103b5b0 Compare June 9, 2026 10:44

@avdv avdv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you @axman6, nice work!

@avdv avdv added the merge-queue merge on green CI label Jun 9, 2026
@mergify mergify Bot added the queued label Jun 9, 2026
@mergify

mergify Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • Entered queue2026-06-09 20:59 UTC · Rule: default
  • Checks skipped · PR is already up-to-date
  • Merged2026-06-09 20:59 UTC · at 103b5b0cd8f0dd96ea7c45a901924da407e40c71 · merge

This pull request spent 20 seconds in the queue, including 3 seconds running CI.

Required conditions to merge
  • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = deploy/netlify
    • check-neutral = deploy/netlify
    • check-skipped = deploy/netlify
  • any of [🛡 GitHub branch protection]:
    • check-success = all_ci_tests
    • check-neutral = all_ci_tests
    • check-skipped = all_ci_tests

@mergify mergify Bot merged commit 82ad95f into master Jun 9, 2026
121 of 124 checks passed
@mergify mergify Bot deleted the axman6/2328-use-starlark-rules branch June 9, 2026 20:59
@mergify mergify Bot removed queued merge-queue merge on green CI labels Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Load rules from Starlark

2 participants