ChanServ changed the topic of #zig to: zig programming language | https://ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
<daurnimator> oats: looks like you're compiling for freestanding.... but a library you're linking against assumes libc exists.
<oats> yeah, it's supposed to be freestanding, but I guess I need libc
<daurnimator> oats: If you're freestanding.... then there is no OS to provide the functions like `puts`.
<daurnimator> oats: which is to say, those libraries you're linking.... they seem to not be providing things you're using?
<oats> the stdio.s I'm using has a __io_putchar implementation
<oats> and also sets stdout_ptr
<daurnimator> oats: are those concepts from your libc?
<oats> I *believe* so
<oats> this is the libc I have installed
<daurnimator> oats: how are you linking to that?
<daurnimator> (I don't see it in your zig build line? or I'm blind...)
<oats> I formatted the command nicely
<daurnimator> oats: ah. the libc.a wasn't in the one you pasted previously
<daurnimator> oats: I'm not sure if you should use `--libc` argument..... this isn't an area I've used yet.
<oats> ah, my apologies :<
<oats> I've fiddled with the flags a few times
<daurnimator> oats: every time I've seen andrewrk talk about it he seems to say `--library c`.
<oats> --libc [file] Provide a file which specifies libc paths
<oats> how would I go about finding/making this file
<daurnimator> so I'd add that. and then assume it figures it out from your --library-path
* daurnimator is guessing here.
<oats> ok
<oats> I'll try stuff \o/
<oats> Cannot link against libc for non-native OS 'freestanding' without providing a libc installation file.
<oats> ooh
<oats> zig libc --help
<daurnimator> oats: ah. I guess try writing up a libc file for your target using output of `zig libc` as a template?
<oats> seems so :D
<oats> hm
<oats> the only directory I can find for sure is include_dir
<oats> no dice on crt_dir, lib_dir, static_lib_dir, or dynamic_linker_path
<oats> like having a dynamic linker is useful here :P
<oats> actually, maybe crtbegin.o
<oats> uh, for static_lib_dir
mnoronha has joined #zig
redj has quit [Ping timeout: 255 seconds]
redj has joined #zig
scientes has joined #zig
<daurnimator> Is this meant to work?? error: expected type '[*c]const u8', found '(null)'
<daurnimator> How do I pass a null pointer to a C library that takes a [*c]const u8?
<daurnimator> just `0` I guess? seems to compile. that's sorta scary.....
<daurnimator> I also have a different question; I'm getting a syntax error trying to call a function at the top level. see https://gist.github.com/daurnimator/627630c616aa8a1fbee4fe03f87a3d35
mnoronha has quit [Ping timeout: 244 seconds]
mnoronha has joined #zig
noonien has quit [Quit: Connection closed for inactivity]
a_chou has joined #zig
a_chou has quit [Client Quit]
scientes has quit [Remote host closed the connection]
mnoronha has quit [Ping timeout: 240 seconds]
mnoronha has joined #zig
scientes has joined #zig
mnoronha has quit [Ping timeout: 245 seconds]
mikdusan has joined #zig
mikdusan has quit [Client Quit]
Zaab1t has joined #zig
mnoronha has joined #zig
mnoronha has quit [Ping timeout: 255 seconds]
mnoronha has joined #zig
scientes has quit [Ping timeout: 255 seconds]
brakmic has joined #zig
mnoronha has quit [Ping timeout: 245 seconds]
mnoronha has joined #zig
brakmic has quit [Ping timeout: 250 seconds]
mnoronha has quit [Ping timeout: 240 seconds]
fsateler_ has joined #zig
fsateler has quit [Ping timeout: 250 seconds]
Zaab1t has quit [Quit: bye bye friends]
walac has quit [Ping timeout: 264 seconds]
walac has joined #zig
marmotini_ has joined #zig
brakmic has joined #zig
brakmic has quit [Remote host closed the connection]
brakmic has joined #zig
brakmic has quit [Ping timeout: 255 seconds]
brakmic has joined #zig
very-mediocre has joined #zig
brakmic_ has joined #zig
brakmic has quit [Ping timeout: 268 seconds]
brakmic_ has quit []
kristate has quit [Remote host closed the connection]
slugmatt_ has joined #zig
dch has quit []
dch has joined #zig
porky11 has joined #zig
porky11 has quit [Quit: Leaving]
Zaab1t has joined #zig
<andrewrk> daurnimator, a function call is not a valid top level declaration
<andrewrk> a comptime block is, however
Zaab1t has quit [Quit: bye bye friends]
noonien has joined #zig
develonepi3 has joined #zig
kristate has joined #zig
kristate has quit [Ping timeout: 240 seconds]
tgschultz has quit [Ping timeout: 252 seconds]
<andrewrk> huh, turns out you can link multiple objects into one object
__Myst__ has quit [Read error: Connection reset by peer]
MajorLag has joined #zig
MajorLag has quit [Ping timeout: 259 seconds]
<oats> andrewrk: good morning. are you able to read over my question from yesterday evening?
<andrewrk> hi oats
<andrewrk> can you repeat it? where did you leave off?
__Myst__ has joined #zig
<oats> ok, lemme try to condense
<oats> I'm trying to build a binary for my stm32f0discovery arm board
<oats> I'm using the libopencm3 firmware library
<oats> also trying to build with this libc: http://www.sourceware.org/newlib/
<oats> there's the zig file
<oats> there's the build command I'm using
<andrewrk> looks goodf
<oats> when I try to to build, I get these errors
<oats> I don't know where to find those symbols, and I don't think manually trying to lasso in libc is the best path here
<oats> daurnimator pointed me in the direction of `--library c` and `--libc` yesterday, but I was unable to find all the directories I needed to set in the libc paths file
<andrewrk> --library c and --libc are not relevant for freestanding
<oats> ok
<andrewrk> your libc.a file seems to depend on other .a files or .o files
Guest62170 has joined #zig
Guest62170 is now known as hg
<andrewrk> you might have to define those yourself
<oats> hg: good morning, didn't know you hung out in here :)
<andrewrk> I don't know how newlib works
<oats> ok
<andrewrk> but libc on freestanding doesn't make a lot of sense, since it's operating-system abstractions
<hg> oats: indeed :)
<hg> trying to absorb knowledge from those more knowledgeable than I
<oats> newlib is designed for embedded systems
marmotini_ has quit [Ping timeout: 240 seconds]
<oats> the main thing I want is string printing/formatting :P
<andrewrk> oats, I'm pretty sure you'd have the same question if you were using C
<oats> the stdio.s file I'm using provides an implementation of __io_putchar that uses the serial port
<andrewrk> might be a question for #osdev ("why am I getting undefined symbol _read when using newlib?")
<oats> ok
<oats> I may take it to them later then :)
<andrewrk> or you might need to read the newlib docs. you might be missing libs on the build command
<andrewrk> the __aeabi_idiv though, that's a TODO in zig. I can see if there's an implementation available in llvm's compiler_rt to port
<andrewrk> you can always provide it yourself as a workaround
<oats> what is __aeabi_idiv?
<oats> or, how can I found out more about it
* oats doesn't have a great grasp of libc or the linker
<andrewrk> it's a function that implements signed division on armv6m for 64 bit integers
<andrewrk> since the architecture isn't capable of doing it in hardware
<oats> gotcha
<andrewrk> actually appears to implement 32 bit signed integer division, not 64
<andrewrk> oats, I'll make you a deal - if you get it down to just the __aeabi_idiv linker error, I'll pause what I'm doing and port it for you
<oats> hah, you're great
<oats> I'm about to start a day of classes, but I'll try to peek at it later today
raoof has joined #zig
mnoronha has joined #zig
mnoronha has quit [Ping timeout: 240 seconds]
mnoronha has joined #zig
marmotini_ has joined #zig
tgschultz has joined #zig
Zaab1t has joined #zig
return0e has quit [Remote host closed the connection]
raoof has quit [Quit: Page closed]
mnoronha has quit [Ping timeout: 245 seconds]
return0e has joined #zig
brakmic has joined #zig
mnoronha has joined #zig
brakmic_ has joined #zig
mnoronha has quit [Ping timeout: 240 seconds]
brakmic has quit [Ping timeout: 255 seconds]
Akuli has joined #zig
Avila has joined #zig
MajorLag has joined #zig
tgschultz has quit [Ping timeout: 240 seconds]
MajorLag is now known as tgschultz
marmotini_ has quit [Ping timeout: 255 seconds]
MajorLag has joined #zig
tgschultz has quit [Ping timeout: 250 seconds]
MajorLag is now known as tgschultz
<daurnimator> andrewrk: is passing `0` to a function expecting a `[*c]const u8` the intended way to pass null?
mnoronha has joined #zig
kristate has joined #zig
mnoronha has quit [Ping timeout: 245 seconds]
kristate has quit [Ping timeout: 264 seconds]
<Akuli> this code segfaults when it's ran: https://termbin.com/2m1z how should i write Thing.init
<Akuli> ?
<andrewrk> daurnimator, that's correct. see also https://github.com/ziglang/zig/issues/1967
<Akuli> this works but is kind of ugly https://termbin.com/kb4kp
<andrewrk> Akuli, the problem is result.allocator = &result.arena.allocator;
<Akuli> i kinda know what the problem is
<Akuli> result.arena is allocated in the stack, so that's an address of a stack variable
<Akuli> but i don't know what's the idiomatic way to write this instead
<Akuli> i guess it's not two init methods?
<andrewrk> after copy elision + an associated issue is resolved, this will either be a compile error or it will work, with "result" being the memory allocated at the callsite
<andrewrk> in the meantime, you'll have to make your init method take a pointer to Thing
<Akuli> how do i call it then?
<Akuli> oo nevermind
<andrewrk> here's the issue to watch: https://github.com/ziglang/zig/issues/287
<Akuli> var thing: Thing = undefined
<andrewrk> right
<Akuli> makes sense, thanks :)
mnoronha has joined #zig
Ichorio has joined #zig
marmotini_ has joined #zig
brakmic_ has quit []
brakmic has joined #zig
scientes has joined #zig
mnoronha has quit [Ping timeout: 240 seconds]
wootehfoot has joined #zig
bheads has quit [Quit: Konversation terminated!]
bheads has joined #zig
very-mediocre has quit [Ping timeout: 256 seconds]
mnoronha has joined #zig
wootehfoot has quit [Read error: Connection reset by peer]
mnoronha has quit [Ping timeout: 268 seconds]
gunnarahlberg has joined #zig
Avila has quit [Quit: Leaving]
Akuli has quit [Quit: Leaving]
Zaab1t has quit [Quit: bye bye friends]
kristate has joined #zig
kristate has quit [Ping timeout: 240 seconds]
mnoronha has joined #zig
mnoronha has quit [Ping timeout: 255 seconds]
hg has quit [Quit: WeeChat 2.4]
mnoronha has joined #zig
aiwakura has quit [Quit: Ping timeout (120 seconds)]
aiwakura has joined #zig
brakmic has quit [Remote host closed the connection]
brakmic has joined #zig
brakmic has quit [Remote host closed the connection]
brakmic has joined #zig
Ichorio has quit [Ping timeout: 255 seconds]
dewf has joined #zig
mnoronha has quit [Ping timeout: 255 seconds]
mnoronha has joined #zig
marmotini_ has quit [Remote host closed the connection]
mnoronha has quit [Ping timeout: 245 seconds]