[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/beardbolt 7a964319ba 213/323: Merge branch 'zig-0.9' in
From: |
ELPA Syncer |
Subject: |
[elpa] externals/beardbolt 7a964319ba 213/323: Merge branch 'zig-0.9' into 'master' |
Date: |
Thu, 9 Mar 2023 10:58:32 -0500 (EST) |
branch: externals/beardbolt
commit 7a964319baad91ebbbb90aa5262bd136ef358347
Merge: 1b015e8d9b c88196439f
Author: Jay Kamat <jaygkamat@gmail.com>
Commit: Jay Kamat <jaygkamat@gmail.com>
Merge branch 'zig-0.9' into 'master'
Support Zig 0.9
See merge request jgkamat/rmsbolt!11
---
README.org | 12 ++++++++----
doc/rmsbolt.texi | 26 ++++++++++++++++----------
rmsbolt.el | 52 +++++++++++++++++++++-------------------------------
starters/rmsbolt.zig | 41 +++++++++++++++++++++++++----------------
4 files changed, 70 insertions(+), 61 deletions(-)
diff --git a/README.org b/README.org
index 7ea5545424..c957e0ed2a 100644
--- a/README.org
+++ b/README.org
@@ -63,10 +63,14 @@ though.
#+END_SRC
* Running
-Once installed, use the ~rmsbolt-starter~ command to generate starter files, or
-enable ~rmsbolt-mode~ in a supported language. Then run ~rmsbolt-compile~ or
-use the default ~C-c C-c~ binding. After the first run, the buffer should
-automatically update.
+Run ~rmsbolt~ to compile the current buffer. This enables ~rmsbolt-mode~
+for code region highlighting and automatic recompilation on buffer changes.
+
+~rmsbolt-mode~ also adds the key binding ~C-c C-c~ to run a compilation.
+
+Run ~rmsbolt-starter~ to generate an example source file for one of the
supported languages.
+
+Run ~rmsbolt-compile~ to start a compilation without enabling ~rmsbolt-mode~.
Language-specific quirks are listed in the full documentation.
diff --git a/doc/rmsbolt.texi b/doc/rmsbolt.texi
index 5830f07c47..5f4788effe 100644
--- a/doc/rmsbolt.texi
+++ b/doc/rmsbolt.texi
@@ -110,10 +110,15 @@ This is a quelpa formula for RMSbolt
@node Running
@chapter Running
-Once installed, use the @code{rmsbolt-starter} command to generate starter
files, or
-enable @code{rmsbolt-mode} in a supported language. Then run
@code{rmsbolt-compile} or use
-the default @code{C-c C-c} binding to pop open a disassembly buffer. After the
first
-run, the buffer should automatically update.
+Once installed, run @code{rmsbolt} to compile the current buffer.
+This enables @code{rmsbolt-mode} for code region highlighting and
+automatic recompilation on buffer changes.
+
+@code{rmsbolt-mode} also adds the key binding @code{C-c C-c} to run a
compilation.
+
+Run @code{rmsbolt-starter} to generate an example source file for one of the
supported languages.
+
+Run @code{rmsbolt-compile} to start a compilation without enabling
@code{rmsbolt-mode}.
@node Configuring
@chapter Configuring
@@ -310,14 +315,15 @@ supported at the moment, with @code{sbcl} giving much
better results.
Assembly is generated through the @code{zig} compiler. Due to large binary
sizes,
disassembly is discouraged.
-Zig embeds a panic handler which inflates the size of binaries. In order to
-reduce this to a manageable level, you can add the following snippet to your
-file:
+In some cases, Zig embeds a panic handler which inflates the size of binaries.
+In order to reduce this to a manageable level, you can add the following
snippet to
+your file:
@example
-pub fn panic(msg: []const u8, error_return_trace:
?*@@import("builtin").StackTrace) noreturn @{
- while (true) @{
- @}
+pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace)
noreturn @{
+ _ = msg;
+ _ = error_return_trace;
+ while (true) @{@}
@}
@end example
diff --git a/rmsbolt.el b/rmsbolt.el
index 868d263d1a..69cd577ec5 100644
--- a/rmsbolt.el
+++ b/rmsbolt.el
@@ -657,37 +657,17 @@ https://github.com/derickr/vld"
"Process a compile command for zig."
(rmsbolt--with-files
src-buffer
- (let* ((asm-format (buffer-local-value 'rmsbolt-asm-format src-buffer))
- (predicted-asm-filename (shell-quote-argument
- (concat (file-name-directory
output-filename)
- (file-name-as-directory "zig-cache")
- (file-name-sans-extension
(file-name-nondirectory (buffer-file-name)))
- ".s")))
- (disass (buffer-local-value 'rmsbolt-disassemble src-buffer))
+ (let* ((disass (buffer-local-value 'rmsbolt-disassemble src-buffer))
(cmd (buffer-local-value 'rmsbolt-command src-buffer))
- (cmd (mapconcat #'identity
- (list cmd
- "build-exe"
- src-filename
- "--emit"
- (if disass
- "bin"
- "asm")
- (when (and (not (booleanp asm-format))
- (not disass))
- (concat "-mllvm --x86-asm-syntax="
asm-format))
- (mapconcat #'identity
- (cond
- (disass
- (list "--output" output-filename))
- ((equal predicted-asm-filename
output-filename)
- nil)
- (t
- (list "&&" "mv"
- predicted-asm-filename
- output-filename)))
- " "))
- " ")))
+ (cmd (string-join
+ (list cmd
+ src-filename
+ "--cache-dir" (expand-file-name "zig-cache"
rmsbolt--temp-dir)
+ (concat (if disass
+ "-femit-bin="
+ "-fno-emit-bin -femit-asm=")
+ output-filename))
+ " ")))
cmd)))
(cl-defun rmsbolt--swift-compile-cmd (&key src-buffer)
@@ -904,7 +884,7 @@ return t if successful."
lines)
:elisp-compile-override
#'rmsbolt--elisp-compile-override))
(zig-mode
- . ,(make-rmsbolt-lang :compile-cmd "zig"
+ . ,(make-rmsbolt-lang :compile-cmd "zig build-obj -O ReleaseFast"
:supports-asm t
:supports-disass t
:objdumper 'objdump
@@ -1779,6 +1759,16 @@ This mode is enabled both in modes to be compiled and
output buffers."
(t ;; Cleanup
(rmsbolt--cleanup-overlays))))
+;;;###autoload
+(defun rmsbolt ()
+ "Start a rmsbolt compilation and enable `rmsbolt-mode' for code region
+highlighting and automatic recompilation."
+ (interactive)
+ (if rmsbolt-mode
+ (rmsbolt-compile)
+ (rmsbolt-mode)
+ (run-at-time 0 nil (lambda () (rmsbolt-compile)))))
+
(provide 'rmsbolt)
;;; rmsbolt.el ends here
diff --git a/starters/rmsbolt.zig b/starters/rmsbolt.zig
index 60527742ee..ace2786ec6 100644
--- a/starters/rmsbolt.zig
+++ b/starters/rmsbolt.zig
@@ -3,29 +3,38 @@ const std = @import("std");
// Zig rmsbolt starter file
// Local Variables:
-// rmsbolt-command: "zig"
+// rmsbolt-command: "zig build-obj -O ReleaseFast"
// rmsbolt-disassemble: nil
// End:
-fn isRMS(a: u8) u8 {
- switch (a) {
- 'R' => {return 1;},
- 'M' => {return 2;},
- 'S' => {return 3;},
- else => {return 0;},
- }
+export fn isRMS(a: u8) u8 {
+ return switch (a) {
+ 'R' => 1,
+ 'M' => 2,
+ 'S' => 3,
+ else => 0,
+ };
}
-pub fn main() void {
- const a: u8 = 1 + 1;
- if (isRMS(a) != 0) {
- std.debug.warn("{c}\n", a);
+// Functions marked with `export` use the C calling convention, so its
parameters and
+// return value can only have C types.
+// To export a native Zig fn, use the following pattern:
+fn zigFn(xs: []u8) []u8 {
+ for (xs) |*x| {
+ x.* *= 2;
}
+ return xs;
+}
+
+export fn exportZigFn() usize {
+ return @ptrToInt(zigFn);
}
-// Zig embeds a panic handler that prints stack traces, causing a disassembly
much larger than normal.
+// In some cases, Zig embeds a panic handler that prints stack traces, causing
a
+// disassembly much larger than normal.
// You can optionally place this function in files you disassemble to make
them easier to digest.
-pub fn panic(msg: []const u8, error_return_trace:
?*@import("builtin").StackTrace) noreturn {
- while (true) {
- }
+pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace)
noreturn {
+ _ = msg;
+ _ = error_return_trace;
+ while (true) {}
}
- [elpa] externals/beardbolt af0a8a6ec9 189/323: Merge branch 'master' of gitlab.com:jgkamat/rmsbolt, (continued)
- [elpa] externals/beardbolt af0a8a6ec9 189/323: Merge branch 'master' of gitlab.com:jgkamat/rmsbolt, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt fcefc0509d 184/323: Add basic documentation for Swift, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 1b015e8d9b 212/323: Update ci to use alpine directly, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 62e68ea2d4 194/323: Fix overlays not working on first compile with popup, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 536a699d1f 193/323: Clean up overlays and mappings if compilation fails, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt ea3e0e4257 200/323: Fix incorrect matching of filenames for compile_commands.json, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 2bc1afe528 196/323: Strip -save-temps when -P is provided, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 840d7f7a1e 195/323: Add :force t argument to rmsbolt-move-overlays, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt c86cc8f11e 199/323: Fix highlights not working with compile_commands.json in some cases, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 1c0e96060b 229/323: Don't set global kill-buffer-hook, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 7a964319ba 213/323: Merge branch 'zig-0.9' into 'master',
ELPA Syncer <=
- [elpa] externals/beardbolt 981522dcaa 218/323: Improve `rmsbolt-mode` docstring, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 2e1ff0653e 216/323: Correct location of parse hook, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 345059d4f4 219/323: Set `defvar-local` vars with `setq`, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 4f6ffdd254 226/323: Rename rmsbolt-move-overlays -> rmsbolt-update-overlays, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 464b524e49 221/323: Remove redundant `and`, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 51ff24b3b1 217/323: Fix native-comp docstring warnings, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 0bc89903f1 231/323: on-kill-buffer: Fix error on missing output-buffer, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt d09d72f463 215/323: Add after-parse-hook, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt af37266681 227/323: Rename rmsbolt--cleanup-overlays -> rmsbolt--remove-overlays, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt f3fe3d24db 230/323: Don't use a timer for updating overlays, ELPA Syncer, 2023/03/09