Skip to content

Commit c4730ef

Browse files
committed
zig: Bump all programs to Zig 0.15
#### Problem The solana zig compiler is out for Zig 0.15, but all the examples in the repo are still on 0.14. #### Summary of changes Bump all dependencies and versions, along with any fixes required.
1 parent 4a9a00b commit c4730ef

File tree

21 files changed

+108
-157
lines changed

21 files changed

+108
-157
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ a little-endian u64 in instruction data.
167167
| Language | CU Usage |
168168
| --- | --- |
169169
| Rust | 459 |
170-
| Zig | 38 |
170+
| Zig | 37 |
171171
| C | 104 |
172172
| Assembly | 30 |
173173
| Rust (pinocchio) | 28 |
@@ -186,7 +186,7 @@ address and `invoke_signed` to CPI to the system program.
186186
| Language | CU Usage | CU Usage (minus syscalls) |
187187
| --- | --- | --- |
188188
| Rust | 3698 | 1198 |
189-
| Zig | 2809 | 309 |
189+
| Zig | 2967 | 309 |
190190
| C | 3122 | 622 |
191191
| Rust (pinocchio) | 2802 | 302 |
192192

@@ -215,39 +215,39 @@ program.
215215
| Language | CU Usage |
216216
| --- | --- |
217217
| Rust | 1115 |
218-
| Zig | 152 |
218+
| Zig | 142 |
219219

220220
* Initialize Account
221221

222222
| Language | CU Usage |
223223
| --- | --- |
224224
| Rust | 2071 |
225-
| Zig | 175 |
225+
| Zig | 158 |
226226

227227
* Mint To
228228

229229
| Language | CU Usage |
230230
| --- | --- |
231231
| Rust | 2189 |
232-
| Zig | 154 |
232+
| Zig | 133 |
233233

234234
* Transfer
235235

236236
| Language | CU Usage |
237237
| --- | --- |
238238
| Rust | 2208 |
239-
| Zig | 145 |
239+
| Zig | 124 |
240240

241241
* Burn
242242

243243
| Language | CU Usage |
244244
| --- | --- |
245245
| Rust | 2045 |
246-
| Zig | 141 |
246+
| Zig | 123 |
247247

248248
* Close Account
249249

250250
| Language | CU Usage |
251251
| --- | --- |
252252
| Rust | 1483 |
253-
| Zig | 122 |
253+
| Zig | 114 |

cpi/zig/build.zig

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@ const solana = @import("solana_program_sdk");
44
pub fn build(b: *std.Build) !void {
55
const target = b.resolveTargetQuery(solana.sbf_target);
66
const optimize = .ReleaseFast;
7-
87
const dep_opts = .{ .target = target, .optimize = optimize };
98

109
const solana_lib_dep = b.dependency("solana_program_library", dep_opts);
1110
const solana_lib_mod = solana_lib_dep.module("solana_program_library");
1211

13-
const program = b.addSharedLibrary(.{
12+
const program = b.addLibrary(.{
1413
.name = "solana_program_rosetta_cpi",
15-
.root_source_file = b.path("main.zig"),
16-
.target = target,
17-
.optimize = optimize,
14+
.linkage = .dynamic,
15+
.root_module = b.createModule(.{
16+
.root_source_file = b.path("main.zig"),
17+
.optimize = optimize,
18+
.target = target,
19+
})
1820
});
1921

2022
program.root_module.addImport("solana_program_library", solana_lib_mod);

cpi/zig/build.zig.zon

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

77
.dependencies = .{
88
.solana_program_sdk = .{
9-
.url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.16.2.tar.gz",
10-
.hash = "solana_program_sdk-0.16.2-wGj9UHXjAAAK5z6ZdLUJ5uu2SxgE8o7ZJ9Il4EG22IJP",
9+
.url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.17.1.tar.gz",
10+
.hash = "solana_program_sdk-0.17.1-wGj9UBrlAADAagTi3MSX1vSpGg-DePWB_5znbUgMlH1U",
1111
},
1212
.solana_program_library = .{
13-
.url = "https://github.com/joncinque/solana-program-library-zig/archive/refs/tags/v0.15.1.tar.gz",
14-
.hash = "solana_program_library-0.15.1-10r-le4EAQBXCYrq-CeWEKfTnJEh29ErMm8tA46Mi2Dd",
13+
.url = "https://github.com/joncinque/solana-program-library-zig/archive/refs/tags/v0.16.1.tar.gz",
14+
.hash = "solana_program_library-0.16.1-10r-lcr-AACkeemV1ql6olBAHLdID3JPJmGcNsx1gayC",
1515
},
1616
},
1717

cpi/zig/main.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ const system_ix = sol_lib.system;
55
const SIZE = 42;
66

77
export fn entrypoint(input: [*]u8) u64 {
8-
const context = sol.Context.load(input) catch return 1;
8+
const context = sol.context.Context.load(input) catch return 1;
99
const allocated = context.accounts[0];
1010

11-
const expected_allocated_key = sol.PublicKey.createProgramAddress(
11+
const expected_allocated_key = sol.public_key.PublicKey.createProgramAddress(
1212
&.{ "You pass butter", &.{context.data[0]} },
1313
context.program_id.*,
1414
) catch return 1;

helloworld/zig/build.zig

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ const solana = @import("solana_program_sdk");
44
pub fn build(b: *std.Build) !void {
55
const target = b.resolveTargetQuery(solana.sbf_target);
66
const optimize = .ReleaseFast;
7-
const program = b.addSharedLibrary(.{
7+
const program = b.addLibrary(.{
88
.name = "solana_program_rosetta_helloworld",
9-
.root_source_file = b.path("main.zig"),
10-
.target = target,
11-
.optimize = optimize,
9+
.linkage = .dynamic,
10+
.root_module = b.createModule(.{
11+
.root_source_file = b.path("main.zig"),
12+
.optimize = optimize,
13+
.target = target,
14+
})
1215
});
1316
_ = solana.buildProgram(b, program, target, optimize);
1417
b.installArtifact(program);

helloworld/zig/build.zig.zon

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,19 @@
11
.{
22
.name = .solana_rosetta_helloworld,
33
.fingerprint = 0x34d885e7d0be5910,
4-
// This is a [Semantic Version](https://semver.org/).
5-
// In a future version of Zig it will be used for package deduplication.
6-
.version = "0.13.0",
7-
8-
// This field is optional.
9-
// This is currently advisory only; Zig does not yet do anything
10-
// with this value.
11-
.minimum_zig_version = "0.14.0",
12-
13-
// This field is optional.
14-
// Each dependency must either provide a `url` and `hash`, or a `path`.
15-
// `zig build --fetch` can be used to fetch all dependencies of a package, recursively.
16-
// Once all dependencies are fetched, `zig build` no longer requires
17-
// internet connectivity.
4+
.version = "0.15.0",
5+
.minimum_zig_version = "0.15.0",
186
.dependencies = .{
197
.base58 = .{
20-
.url = "https://github.com/joncinque/base58-zig/archive/refs/tags/v0.14.0.tar.gz",
21-
.hash = "base58-0.14.0-6-CZm81qAAD4JCRHgewcNh8FS0pmnk7-OmwUkosaFKvg",
8+
.url = "https://github.com/joncinque/base58-zig/archive/refs/tags/v0.15.0.tar.gz",
9+
.hash = "base58-0.15.0-6-CZmwVpAAAxqof6REya9G_XyHL1fTqUsAcsZ-J1IHMF",
2210
},
2311
.solana_program_sdk = .{
24-
.url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.16.2.tar.gz",
25-
.hash = "solana_program_sdk-0.16.2-wGj9UHXjAAAK5z6ZdLUJ5uu2SxgE8o7ZJ9Il4EG22IJP",
12+
.url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.17.0.tar.gz",
13+
.hash = "solana_program_sdk-0.17.0-wGj9UHjiAAC5lyL1BQ4MI7wcQYrqSjHrxdvZXDaA8Glb",
2614
},
2715
},
28-
29-
// Specifies the set of files and directories that are included in this package.
30-
// Only files and directories listed here are included in the `hash` that
31-
// is computed for this package.
32-
// Paths are relative to the build root. Use the empty string (`""`) to refer to
33-
// the build root itself.
34-
// A directory listed here means that all files within, recursively, are included.
3516
.paths = .{
36-
// For example...
3717
"build.zig",
3818
"build.zig.zon",
3919
"src",

helloworld/zig/main.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const sol = @import("solana_program_sdk");
22

33
export fn entrypoint(_: [*]u8) u64 {
4-
sol.log("Hello world!");
4+
sol.log.log("Hello world!");
55
return 0;
66
}

install-solana-zig.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
if [[ -n $SOLANA_ZIG_VERSION ]]; then
44
solana_zig_version="$SOLANA_ZIG_VERSION"
55
else
6-
solana_zig_version="v1.47.0"
6+
solana_zig_version="v1.52.0"
77
fi
88
solana_zig_release_url="https://github.com/joncinque/solana-zig-bootstrap/releases/download/solana-$solana_zig_version"
99

pubkey/zig/build.zig

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ const solana = @import("solana_program_sdk");
44
pub fn build(b: *std.Build) !void {
55
const target = b.resolveTargetQuery(solana.sbf_target);
66
const optimize = .ReleaseFast;
7-
const program = b.addSharedLibrary(.{
7+
const program = b.addLibrary(.{
88
.name = "solana_program_rosetta_pubkey",
9-
.root_source_file = b.path("main.zig"),
10-
.target = target,
11-
.optimize = optimize,
9+
.linkage = .dynamic,
10+
.root_module = b.createModule(.{
11+
.root_source_file = b.path("main.zig"),
12+
.optimize = optimize,
13+
.target = target,
14+
})
1215
});
1316
_ = solana.buildProgram(b, program, target, optimize);
1417
b.installArtifact(program);

pubkey/zig/build.zig.zon

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
11
.{
22
.name = .solana_rosetta_pubkey,
33
.fingerprint = 0xa8636daaef29becd,
4-
// This is a [Semantic Version](https://semver.org/).
5-
// In a future version of Zig it will be used for package deduplication.
6-
.version = "0.13.0",
7-
8-
// This field is optional.
9-
// This is currently advisory only; Zig does not yet do anything
10-
// with this value.
11-
.minimum_zig_version = "0.14.0",
12-
13-
// This field is optional.
14-
// Each dependency must either provide a `url` and `hash`, or a `path`.
15-
// `zig build --fetch` can be used to fetch all dependencies of a package, recursively.
16-
// Once all dependencies are fetched, `zig build` no longer requires
17-
// internet connectivity.
4+
.version = "0.15.0",
5+
.minimum_zig_version = "0.15.0",
186
.dependencies = .{
197
.solana_program_sdk = .{
20-
.url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.16.2.tar.gz",
21-
.hash = "solana_program_sdk-0.16.2-wGj9UHXjAAAK5z6ZdLUJ5uu2SxgE8o7ZJ9Il4EG22IJP",
8+
.url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.17.0.tar.gz",
9+
.hash = "solana_program_sdk-0.17.0-wGj9UHjiAAC5lyL1BQ4MI7wcQYrqSjHrxdvZXDaA8Glb",
2210
},
2311
},
2412
.paths = .{

0 commit comments

Comments
 (0)