Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Duplicate entries in solve_for_platforms currently break result merging. Record the
failure before joint solving deduplicates the requested platform set.

$ mkrepo
$ add_mock_repo_if_needed

Make a package:
$ mkpkg foo <<EOF
> build: [
> ["mkdir" "-p" "%{lib}%/%{name}%"]
> ["touch" "%{lib}%/%{name}%/META"] # needed for dune to recognize this as a library
> ]
> EOF

$ make_portable_lockdirs_project

Solve for a platform set that contains the same platform twice:
$ cat > dune-workspace <<EOF
> (lang dune 3.11)
> (repository
> (name mock)
> (url "file://$(pwd)/mock-opam-repository"))
> (lock_dir
> (repositories mock)
> (solve_for_platforms
> ((arch arm64) (os macos))
> ((arch arm64) (os macos))
> ((arch x86_64) (os linux))))
> EOF

Merging successful per-platform results rejects the duplicate solver
environment:

$ dune pkg lock >output 2>&1
[1]
$ grep 'Tried to add duplicate solver env' output
("Tried to add duplicate solver env to lockdir conditional choice",

When solving fails before result merging, the duplicate platform is reported
twice:

$ mkpkg foo <<'EOF'
> available: false
> EOF
$ dune pkg lock >output 2>&1
[1]
$ grep 'arch = arm64; os = macos' output
- arch = arm64; os = macos
- arch = arm64; os = macos
$ grep 'arch = x86_64; os = linux' output
- arch = x86_64; os = linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
A malformed repository version that cannot satisfy a local package constraint
must not prevent the solver from selecting a valid version.

$ mkrepo
$ add_mock_repo_if_needed

$ mkpkg foo 1 <<'EOF'
> EOF

Version 2 is malformed, but the local constraint makes it impossible before its
manifest needs to be loaded.

$ mkpkg foo 2 <<'EOF'
> depends: [
> EOF

$ cat >dune-project <<'EOF'
> (lang dune 3.18)
> (package
> (name x)
> (depends (foo (= 1))))
> EOF

$ dune pkg lock
Solution for dune.lock

Dependencies common to all supported platforms:
- foo.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
A local package dependency alternative may select a different package on each
platform. Preserve every package selected by the per-platform solves when
constructing the portable lock directory.

$ mkrepo
$ add_mock_repo_if_needed

$ mkpkg linux-impl <<'EOF'
> available: os = "linux"
> EOF
$ mkpkg macos-impl <<'EOF'
> available: os = "macos"
> EOF

The local package accepts either implementation. Package availability forces
Linux and macOS to select different branches of the disjunction.

$ cat >dune-project <<'EOF'
> (lang dune 3.18)
> EOF
$ cat >x.opam <<'EOF'
> opam-version: "2.0"
> depends: [ "linux-impl" | "macos-impl" ]
> EOF

$ dune pkg lock
Solution for dune.lock

Dependencies common to all supported platforms:
(none)

Additionally, some packages will only be built on specific platforms.

arch = arm64; os = linux:
- linux-impl.0.0.1

arch = arm64; os = macos:
- macos-impl.0.0.1

arch = x86_64; os = linux:
- linux-impl.0.0.1

arch = x86_64; os = macos:
- macos-impl.0.0.1
$ ls dune.lock/*.pkg | sort
dune.lock/linux-impl.0.0.1.pkg
dune.lock/macos-impl.0.0.1.pkg
Loading