Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build from source code #15

Open
Spoiledpay opened this issue Aug 2, 2024 · 2 comments
Open

Build from source code #15

Spoiledpay opened this issue Aug 2, 2024 · 2 comments

Comments

@Spoiledpay
Copy link

Hello! I hope you are well!

I tried and I don't even know if I did it the right way. I downloaded the new Adept 3.x compiler. I installed the Rustc compiler.

I used Cargo Build and it didn't compile, I imagine something is missing for completion. Something related to LLVM.

Error

@IsaacShelton
Copy link
Owner

IsaacShelton commented Aug 2, 2024

Yes, it needs the path to LLVM in order to build it.

For example,

LLVM_SYS_181_PREFIX="/opt/homebrew/opt/llvm" cargo build

On Windows, this would be a different path, and would depend on how to obtained your copy of llvm 18.1.

Also as a side note, it is not in a usable state yet. Only the support for arm64 macOS is finished at the moment, although I just added bare-bones support for unfinished platforms in the latest commits 7c46f57 and 16f4867. So it is possible to use it on Windows, it just requires manual linking (with mingw64 for example) and doesn't support complicated C ABI interoperability yet (only basic types can be passed to C functions).

The only parts that are mostly stable right now are simple single file programs using the C standard library.

And being the early development days, everything is still subject to change. Some features are having their designs revisited too, so even if something works it might not be final. These include but are not limited to: structures, memory management, multi-file programs, integer overflow behavior, primitive type names, syntax used and more.

Here some example programs in the current iteration though:

#[foreign]
func printf(format ptr<u8>, ...) i32

func main {
    printf(c"Hello, World!")
}
#[foreign]
func printf(format ptr<u8>, ...) i32

func main {
    a i32 = 10
    b u32 = 4

    // This variable will be an i64, since i64 is the smallest type
    // that can safely represent the result of (i32 + u32)
    c := a + b

    printf(c"result is %lld\n", c)
}
#[foreign]
{
    func printf(format ptr<u8>, ...) i32
    func strcmp(a ptr<u8>, b ptr<u8>) i32
    func atoi(string ptr<u8>) i32
}

func main(argc i32, argv ptr<ptr<u8>>) i32 {
    if argc < 2 {
        printf(c"USAGE: %s <number-name>\n", argv[0])
        return 1
    }

    number ptr<u8> = argv[1]

    printf(c"Your number is: %s\n", if strcmp(number, c"one") == 0 {
        c"1"
    } elif strcmp(number, c"two") == 0 {
        c"2"
    } elif strcmp(number, c"three") == 0 {
        c"3"
    } else {
        c"I'm not sure"
    })

    return 0
}
#[foreign]
{
    func printf(format ptr<u8>, ...) i32
    func malloc(size uint) ptr<void>
    func free(pointer ptr<void>) void
}

func main {
    items ptr<i32> = malloc(4 * 10)

    i i32 = 0
    while i < 10 {
        items[i] = 10 * i
        i += 1
    }

    i i32 = 0
    while i < 10 {
        printf(c"items[%d] = %d\n", i, items[i])
        i += 1
    }

    free(items)
}

@Curculigo
Copy link

@Spoiledpay On Windows, please use MSYS2. It will be very straight forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants