Skip to content

Commit 3d196f3

Browse files
authored
pkg: set arch variable when solving portable lockdir (ocaml#11927)
Without the `arch` variable set to a known architecture the `ocaml-compiler` package only installs the bytecode compiler. This change sets `arch` to `x86_64` and `arm64` in the default solver environments. Signed-off-by: Stephen Sherratt <[email protected]>
1 parent 0ba42f1 commit 3d196f3

File tree

3 files changed

+65
-17
lines changed

3 files changed

+65
-17
lines changed

src/dune_pkg/solver_env.ml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,12 @@ let popular_platform_envs =
143143
in
144144
env
145145
in
146-
[ make ~os:"linux" ~arch:None ~os_distribution:None ~os_family:None ()
147-
; make ~os:"macos" ~arch:None ~os_distribution:None ~os_family:None ()
148-
; make ~os:"win32" ~arch:None ~os_distribution:None ~os_family:None ()
146+
[ make ~os:"linux" ~arch:(Some "x86_64") ~os_distribution:None ~os_family:None ()
147+
; make ~os:"linux" ~arch:(Some "arm64") ~os_distribution:None ~os_family:None ()
148+
; make ~os:"macos" ~arch:(Some "x86_64") ~os_distribution:None ~os_family:None ()
149+
; make ~os:"macos" ~arch:(Some "arm64") ~os_distribution:None ~os_family:None ()
150+
; make ~os:"win32" ~arch:(Some "x86_64") ~os_distribution:None ~os_family:None ()
151+
; make ~os:"win32" ~arch:(Some "arm64") ~os_distribution:None ~os_family:None ()
149152
]
150153
;;
151154

test/blackbox-tests/test-cases/pkg/portable-lockdirs/portable-lockdirs-basic.t

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,36 +46,65 @@ Create a package that writes a different value to some files depending on the os
4646
(complete false)
4747
(used))
4848

49-
(solved_for_platforms ((os linux)) ((os macos)) ((os win32)))
49+
(solved_for_platforms
50+
((arch x86_64)
51+
(os linux))
52+
((arch arm64)
53+
(os linux))
54+
((arch x86_64)
55+
(os macos))
56+
((arch arm64)
57+
(os macos))
58+
((arch x86_64)
59+
(os win32))
60+
((arch arm64)
61+
(os win32)))
5062

5163
$ cat dune.lock/foo.0.0.1.pkg
5264
(version 0.0.1)
5365

5466
(build
5567
(choice
56-
((((os linux)))
68+
((((arch x86_64) (os linux)))
5769
((action
5870
(progn
5971
(run mkdir -p %{share} %{lib}/%{pkg-self:name})
6072
(run touch %{lib}/%{pkg-self:name}/META)
6173
(run sh -c "echo Linux > %{share}/kernel")
62-
(when (= %{arch} x86_64) (run sh -c "echo x86_64 > %{share}/machine"))
63-
(when (= %{arch} arm64) (run sh -c "echo arm64 > %{share}/machine"))))))
64-
((((os macos)))
74+
(run sh -c "echo x86_64 > %{share}/machine")))))
75+
((((arch arm64) (os linux)))
76+
((action
77+
(progn
78+
(run mkdir -p %{share} %{lib}/%{pkg-self:name})
79+
(run touch %{lib}/%{pkg-self:name}/META)
80+
(run sh -c "echo Linux > %{share}/kernel")
81+
(run sh -c "echo arm64 > %{share}/machine")))))
82+
((((arch x86_64) (os macos)))
83+
((action
84+
(progn
85+
(run mkdir -p %{share} %{lib}/%{pkg-self:name})
86+
(run touch %{lib}/%{pkg-self:name}/META)
87+
(run sh -c "echo Darwin > %{share}/kernel")
88+
(run sh -c "echo x86_64 > %{share}/machine")))))
89+
((((arch arm64) (os macos)))
6590
((action
6691
(progn
6792
(run mkdir -p %{share} %{lib}/%{pkg-self:name})
6893
(run touch %{lib}/%{pkg-self:name}/META)
6994
(run sh -c "echo Darwin > %{share}/kernel")
70-
(when (= %{arch} x86_64) (run sh -c "echo x86_64 > %{share}/machine"))
71-
(when (= %{arch} arm64) (run sh -c "echo arm64 > %{share}/machine"))))))
72-
((((os win32)))
95+
(run sh -c "echo arm64 > %{share}/machine")))))
96+
((((arch x86_64) (os win32)))
97+
((action
98+
(progn
99+
(run mkdir -p %{share} %{lib}/%{pkg-self:name})
100+
(run touch %{lib}/%{pkg-self:name}/META)
101+
(run sh -c "echo x86_64 > %{share}/machine")))))
102+
((((arch arm64) (os win32)))
73103
((action
74104
(progn
75105
(run mkdir -p %{share} %{lib}/%{pkg-self:name})
76106
(run touch %{lib}/%{pkg-self:name}/META)
77-
(when (= %{arch} x86_64) (run sh -c "echo x86_64 > %{share}/machine"))
78-
(when (= %{arch} arm64) (run sh -c "echo arm64 > %{share}/machine"))))))))
107+
(run sh -c "echo arm64 > %{share}/machine")))))))
79108

80109
$ DUNE_CONFIG__ARCH=arm64 dune build
81110
$ cat $pkg_root/foo/target/share/kernel

test/blackbox-tests/test-cases/pkg/portable-lockdirs/portable-lockdirs-partial-solve.t

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ The log file will contain errors about the package being unavailable.
5151
# - foo -> (problem)
5252
# No usable implementations:
5353
# foo.0.0.1: Availability condition not satisfied
54+
# Couldn't solve the package dependency formula.
55+
# Selected candidates: x.dev
56+
# - foo -> (problem)
57+
# No usable implementations:
58+
# foo.0.0.1: Availability condition not satisfied
59+
# Couldn't solve the package dependency formula.
60+
# Selected candidates: x.dev
61+
# - foo -> (problem)
62+
# No usable implementations:
63+
# foo.0.0.1: Availability condition not satisfied
5464

5565
The lockdir will contain a list of the platforms where solving succeeded.
5666
$ cat dune.lock/lock.dune
@@ -62,16 +72,22 @@ The lockdir will contain a list of the platforms where solving succeeded.
6272
(complete false)
6373
(used))
6474

65-
(solved_for_platforms ((os macos)))
75+
(solved_for_platforms
76+
((arch x86_64)
77+
(os macos))
78+
((arch arm64)
79+
(os macos)))
6680

6781
No errors when you try to build the platform on macos.
6882
$ DUNE_CONFIG__OS=macos DUNE_CONFIG__ARCH=x86_64 DUNE_CONFIG__OS_FAMILY=homebrew DUNE_CONFIG__OS_DISTRIBUTION=homebrew DUNE_CONFIG__OS_VERSION=15.3.1 dune build
6983

7084
Building on linux fails because the lockdir doesn't contain a compatible solution.
7185
$ DUNE_CONFIG__OS=linux DUNE_CONFIG__ARCH=arm64 DUNE_CONFIG__OS_FAMILY=debian DUNE_CONFIG__OS_DISTRIBUTION=ubuntu DUNE_CONFIG__OS_VERSION=24.11 dune build
72-
File "dune.lock/lock.dune", line 9, characters 22-34:
73-
9 | (solved_for_platforms ((os macos)))
74-
^^^^^^^^^^^^
86+
File "dune.lock/lock.dune", lines 10-13, characters 1-58:
87+
10 | ((arch x86_64)
88+
11 | (os macos))
89+
12 | ((arch arm64)
90+
13 | (os macos)))
7591
Error: The lockdir does not contain a solution compatible with the current
7692
platform.
7793
The current platform is:

0 commit comments

Comments
 (0)