Skip to content
This repository was archived by the owner on Nov 11, 2021. It is now read-only.

Adding arm64 support for Porth. With -ARCH flag user can spesify - #63

Closed
lntrx wants to merge 22 commits into
tsoding:masterfrom
lntrx:arm64
Closed

lntrx wants to merge 22 commits into
tsoding:masterfrom
lntrx:arm64

Conversation

@lntrx

@lntrx lntrx commented Sep 28, 2021

Copy link
Copy Markdown

either arm64 or x86_64 right now. Default value is platform.arch().
Arm64 uses aarch64-linux-gnu-as assembler.

either arm64 or x86_64 right now. Default value is platform.arch().
Arm64 uses `aarch64-linux-gnu-as` assembler.
Comment thread std/arm64/std.porth Outdated
@rexim

rexim commented Sep 28, 2021

Copy link
Copy Markdown
Member

Is there any way we can test this on CI?

@lntrx

lntrx commented Sep 28, 2021

Copy link
Copy Markdown
Author

Is there any way we can test this on CI?

I use QEMU + Ubuntu 20 to test Arm64. It's easy to install.

@lntrx

lntrx commented Sep 28, 2021

Copy link
Copy Markdown
Author

Is there any way we can test this on CI?

Maybe using qemu-aarch64 ?

With using qemu-* we can test architectures easily.
Tests can be done for both architectures.
@lntrx

lntrx commented Sep 28, 2021

Copy link
Copy Markdown
Author

I added some new modifications, which make it easy to test for both architectures. Output is below

@lntrx

lntrx commented Sep 28, 2021 •

Copy link
Copy Markdown
Author

[INFO] Testing ./tests/mutually-recursive-macros.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/mutually-recursive-macros.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/mutually-recursive-macros.porth
[INFO] Testing ./tests/argv.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/argv.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/argv.porth
[INFO] Testing ./tests/include-file-not-found-error.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/include-file-not-found-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/include-file-not-found-error.porth
[INFO] Testing ./tests/directly-recursive-macro.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/directly-recursive-macro.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/directly-recursive-macro.porth
[INFO] Testing ./tests/macro-without-end-error.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/macro-without-end-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/macro-without-end-error.porth
[INFO] Testing ./tests/no-include-file-error.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/no-include-file-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/no-include-file-error.porth
[INFO] Testing ./tests/macro-redefinition-error.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/macro-redefinition-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/macro-redefinition-error.porth
[INFO] Testing ./tests/comments.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/comments.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/comments.porth
[INFO] Testing ./tests/macros.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/macros.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/macros.porth
[INFO] Testing ./tests/end-cant-close-error.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/end-cant-close-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/end-cant-close-error.porth
[INFO] Testing ./tests/wrong-include-path-type-error.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/wrong-include-path-type-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/wrong-include-path-type-error.porth
[INFO] Testing ./tests/bitwise.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/bitwise.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/bitwise.porth
[INFO] Testing ./tests/comparison.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/comparison.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/comparison.porth
[INFO] Testing ./tests/no-macro-name-error.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/no-macro-name-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/no-macro-name-error.porth
[INFO] Testing ./tests/unclosed-character-literal-error.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/unclosed-character-literal-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/unclosed-character-literal-error.porth
[INFO] Testing ./tests/arithmetics.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/arithmetics.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/arithmetics.porth
[INFO] Testing ./tests/intrinsic-redefinition-error.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/intrinsic-redefinition-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/intrinsic-redefinition-error.porth
[INFO] Testing ./tests/else-not-inside-if-error.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/else-not-inside-if-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/else-not-inside-if-error.porth
[INFO] Testing ./tests/dead-recursive-macro.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/dead-recursive-macro.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/dead-recursive-macro.porth
[INFO] Testing ./tests/unclosed-block-error.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/unclosed-block-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/unclosed-block-error.porth
[INFO] Testing ./tests/memory.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/memory.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/memory.porth
[INFO] Testing ./tests/stack.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/stack.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/stack.porth
[INFO] Testing ./tests/wrong-macro-name-type-error.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/wrong-macro-name-type-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/wrong-macro-name-type-error.porth
[INFO] Testing ./tests/self-including-file.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/self-including-file.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/self-including-file.porth
[INFO] Testing ./tests/unknown-word-error.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/unknown-word-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/unknown-word-error.porth
[INFO] Testing ./tests/multi-byte-character-literal-error.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/multi-byte-character-literal-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/multi-byte-character-literal-error.porth
[INFO] Testing ./tests/control-flow.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/control-flow.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/control-flow.porth
[INFO] Testing ./tests/unclosed-string-literal-error.porth for arch x86_64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/unclosed-string-literal-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH x86_64 -I ./tests/ com -r -s ./tests/unclosed-string-literal-error.porth
[INFO] Testing ./tests/mutually-recursive-macros.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/mutually-recursive-macros.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/mutually-recursive-macros.porth
[INFO] Testing ./tests/argv.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/argv.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/argv.porth
[INFO] Testing ./tests/include-file-not-found-error.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/include-file-not-found-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/include-file-not-found-error.porth
[INFO] Testing ./tests/directly-recursive-macro.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/directly-recursive-macro.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/directly-recursive-macro.porth
[INFO] Testing ./tests/macro-without-end-error.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/macro-without-end-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/macro-without-end-error.porth
[INFO] Testing ./tests/no-include-file-error.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/no-include-file-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/no-include-file-error.porth
[INFO] Testing ./tests/macro-redefinition-error.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/macro-redefinition-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/macro-redefinition-error.porth
[INFO] Testing ./tests/comments.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/comments.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/comments.porth
[INFO] Testing ./tests/macros.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/macros.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/macros.porth
[INFO] Testing ./tests/end-cant-close-error.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/end-cant-close-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/end-cant-close-error.porth
[INFO] Testing ./tests/wrong-include-path-type-error.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/wrong-include-path-type-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/wrong-include-path-type-error.porth
[INFO] Testing ./tests/bitwise.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/bitwise.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/bitwise.porth
[INFO] Testing ./tests/comparison.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/comparison.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/comparison.porth
[INFO] Testing ./tests/no-macro-name-error.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/no-macro-name-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/no-macro-name-error.porth
[INFO] Testing ./tests/unclosed-character-literal-error.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/unclosed-character-literal-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/unclosed-character-literal-error.porth
[INFO] Testing ./tests/arithmetics.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/arithmetics.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/arithmetics.porth
[INFO] Testing ./tests/intrinsic-redefinition-error.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/intrinsic-redefinition-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/intrinsic-redefinition-error.porth
[INFO] Testing ./tests/else-not-inside-if-error.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/else-not-inside-if-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/else-not-inside-if-error.porth
[INFO] Testing ./tests/dead-recursive-macro.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/dead-recursive-macro.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/dead-recursive-macro.porth
[INFO] Testing ./tests/unclosed-block-error.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/unclosed-block-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/unclosed-block-error.porth
[INFO] Testing ./tests/memory.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/memory.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/memory.porth
[INFO] Testing ./tests/stack.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/stack.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/stack.porth
[INFO] Testing ./tests/wrong-macro-name-type-error.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/wrong-macro-name-type-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/wrong-macro-name-type-error.porth
[INFO] Testing ./tests/self-including-file.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/self-including-file.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/self-including-file.porth
[INFO] Testing ./tests/unknown-word-error.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/unknown-word-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/unknown-word-error.porth
[INFO] Testing ./tests/multi-byte-character-literal-error.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/multi-byte-character-literal-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/multi-byte-character-literal-error.porth
[INFO] Testing ./tests/control-flow.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/control-flow.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/control-flow.porth
[INFO] Testing ./tests/unclosed-string-literal-error.porth for arch aarch64
[CMD] /usr/bin/python3 ./porth.py -I ./tests/ sim ./tests/unclosed-string-literal-error.porth
[CMD] /usr/bin/python3 ./porth.py -ARCH aarch64 -I ./tests/ com -r -s ./tests/unclosed-string-literal-error.porth

Simulation failed: 0, Compilation failed: 0

@SeanMcG

SeanMcG commented Oct 3, 2021 •

Copy link
Copy Markdown

Is there any way we can test this on CI?

Does CI allow for custom Docker images?
Maybe an arm64 cross-assembler would work.

Comment thread porth.py Outdated
@lntrx

lntrx commented Oct 3, 2021

Copy link
Copy Markdown
Author

Is there any way we can test this on CI?

Does CI allow for custom Docker images? Maybe an arm64 cross-assembler would work.

Actually I didn't now CI exist until Tsoding ask it about. I am sorry I haven't used GitHub so actively. I am not sure how CI works.

lntrx added 7 commits October 5, 2021 09:46
khello, so I made some changes.

First of all right now I just added support for arm64 and removed other
things.

I seperated syscalls from std as they are completly different things.
For now syscall file *must* be seperate as it's arch dependent. Only
syscall file will be seperate. Other things can be common. This patch
doesnt change anything, but just adds ARM64 support.
@lntrx

lntrx commented Oct 5, 2021

Copy link
Copy Markdown
Author

Hello guys @rexim @SeanMcG ,

I made some undoes. Right now it only adds arm64 support. Unfortunately it's a must to separate x86 and arm64 syscall files.
For default I added 'include "syscall_x86.porth" to std.porth'
I merged new changes. So there should be no conflict whatsoever.

For CI testing I suggest to use qemu-x86_64 and qemu-aarch64. @SeanMcG could you review it!

@lntrx

lntrx commented Oct 5, 2021

Copy link
Copy Markdown
Author

I think it would be best to make an unistd.porth and make some sort of conditional compilation to add arch spesific syscalls.

@lntrx lntrx closed this Oct 5, 2021
@SeanMcG

SeanMcG commented Oct 5, 2021

Copy link
Copy Markdown

As per CONTRIBUTING.md I know @rexim is not currently looking for MRs for this project as it is still "in flux".

I'll with-hold commentary on this patchset for now, but I would like to add that I am using your architecture framework to port this to powerpc64 as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants