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/
_Vi has quit [Ping timeout: 246 seconds]
_Vi has joined #zig
doesntgolf has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
marijnfs has joined #zig
marijnfs__ has quit [Ping timeout: 268 seconds]
<andrewrk> nice we have our first mips regression caught by CI
<stratact> Awesome
<stratact> andrewrk: I know you're very busy, especially getting Zig ready for 0.5.0 this coming Monday and I was wondering if my PR is mergeable? Or are you saving it until after the release?
<andrewrk> stratact, ah, is that ready for review? I'll give it a look before monday
<stratact> It's been ready for a while :)
<andrewrk> nice I thought you had gotten frustrated and gave up
<stratact> I was getting tired of thinking about it and wanted to finish it up as soon as possible :)
<fengb> Was musl ported to riscv? Or does everything just work like magic
<andrewrk> fengb, I worked with dalias on riscv a bit when llvm9 came out, and carried the resulting patches in zig while waiting for a new release
<andrewrk> all the patches are upstream in master, except 40e77dad836abf130bf49af1838d108f0fc2e94e which I'm confused why they haven't merged upstream yet
<stratact> andrewrk: I'm sorry for being misleading though, I didn't give up on completing it. When you said that large fixed sized buffer are a-okay, that was the que for me to wrap the PR up and ship it. πŸ˜„
<andrewrk> got it :)
<andrewrk> looking forward to reading it
<stratact> Should be a nice and easy read
<stratact> Oh I probably should rebase from master though, since std/ is in lib/
<andrewrk> I heard that git rebase is smart enough to figure it out
<stratact> Awesome, I'll try it
<fengb> Catching up on the stream and holy crap it’s amazing to see the window library be maximally performant without knowing about async
<stratact> andrewrk: Perfection worked as expected. Rebased and squashed.
<andrewrk> thanks! hopefully will get a chance to peek tomorrow. I'm a bit behind on release notes quota today from the stream
<stratact> No worries and thanks
<andrewrk> and I still want to play Noita tonight :)
<stratact> Sounds fun. I'm rebooting into system upgrade, I'll brb
stratact has quit [Quit: Konversation terminated!]
stratact has joined #zig
doesntgolf has quit [Ping timeout: 240 seconds]
dimenus has quit [Ping timeout: 245 seconds]
mahmudov has quit [Remote host closed the connection]
owl_000 has joined #zig
chemist69 has quit [Ping timeout: 246 seconds]
chemist69 has joined #zig
owl_000 has quit [Ping timeout: 265 seconds]
avoidr has quit [Quit: leaving]
<nrdmn> eh, wasn't sure if I should move a few things in std/os/uefi, but I think I'll leave it for now.
<nrdmn> but I've added a PR for allocatePool and exitBootServices, which is what most OS developers will be looking for
<mq32> i'm just watching https://youtu.be/Gv2I7qTux7g?t=2274 and suddenly this happens. had a good laugh, nice job andrewrk! :D
st4ll1 has joined #zig
_Vi has quit [Ping timeout: 240 seconds]
_whitelogger has joined #zig
Hirezias has joined #zig
<ceymard> is it possible to pass defines to `zig translate-c` ?
<ceymard> also, is it normal that translate-c bugs on .h files in my /usr/include ?
st4ll1 has quit [Ping timeout: 268 seconds]
vegai has quit [Changing host]
vegai has joined #zig
<ceymard> andrewrk: is there a way to find in the zig-cache the name of the file responsible for a cimport ?
donpdonp has quit [Read error: Connection reset by peer]
donpdonp has joined #zig
rifkik has joined #zig
owl_000 has joined #zig
<owl_000> currently zig version is 0.4.0, how long it may take to become v 1.0
<owl_000> safety becomes a big buzz word in programing space, how much zig focuses on safety.
<ceymard> null checked pointers that can't be null unless you tell them they can't be
<ceymard> can*
<ceymard> that and the whole slice thing
<ceymard> but for memory leaks you're on your own :)
<owl_000> i am looking for a language which i can keep in my head. zig seems to be that kind of language. best wishes for zig team.
<Yardanico> ceymard: well they're easy to fix :P
<Yardanico> just use valgrind
<ceymard> haha
Hirezias has quit [Ping timeout: 250 seconds]
<rifkik> lol
neceve has joined #zig
<ceymard> can I mix optionals and error types ?
<ceymard> what's the priority when used in if / else ?
<ceymard> if a value is Error!?Type and I use a payload in the if, do I get Type or ?Type ?
utzig has joined #zig
_Vi has joined #zig
rifkik has quit [Read error: Connection reset by peer]
donpdonp has quit [Quit: Ping timeout (120 seconds)]
donpdonp has joined #zig
dimenus has joined #zig
<_Vi> How do I @intCast from `?u64` to `?u32`?
<_Vi> Which way is readable and idiomatic?
<_Vi> Is `if(from_var)|x|@intCast(u32,x)else null` good enough?
<_Vi> Is there a cosy method to hex-print a byte slice in std? Preferably with abbreviation if it is too long.
xyproto has quit [Quit: WeeChat 2.5]
xyproto has joined #zig
<dimenus> unwrap the integer first
<dimenus> eg foo.?
<dimenus> but yes, your if statement will work as well
<dimenus> what's the target for rpi4 bare metal?
<dimenus> oops, ignore that question
Akuli has joined #zig
hasanyasin has joined #zig
halosghost has joined #zig
<ceymard> just for fear that the question has been lost ; is it possible to find out which file a zig-cache/**/cimport.zig corresponds to ?
<andrewrk> ceymard, to pass defines to translate-c make a c file and do whatever defines you want in it
<ceymard> or does cimport contain every symbol ?
<andrewrk> actually zig now has -D as well
<ceymard> wow
<companion_cube> andrewrk: that qemu demo was insane
<ceymard> that's impressive
<ceymard> what about the cimport.zig file ?
<ceymard> does it contain every symbol ?
<ceymard> to all @cImport resolve to a single cimport file with everything ?
<ceymard> s/to/do/
<andrewrk> ceymard, use --verbose-cimport and it'll print the filename of the translated zig file
<andrewrk> each @cImport will be done separately. It's usually advised to combine all your C imports into 1 yourself
<andrewrk> but there are use cases for not doing that
<andrewrk> owl_000, 0.5.0 is monday. it will probably be at least 2 more years until 1.0
<andrewrk> owl_000, regarding safety, someone asked a similar question yesterday and I took the time to make a detailed response: https://www.reddit.com/r/Zig/comments/d9e2s2/questions_about_zigs_memory_safety_runtime/
donaldallen has joined #zig
uranther has quit [Quit: Connection closed for inactivity]
<andrewrk> nrdmn, I'm pretty much going to accept any PR you send my way if it's UEFI related and doesn't affect anything else
<andrewrk> at this point I trust your judgement on these matters
<donaldallen> const lib = @import("../library/lib.zig"); results in the compiler error: import of file outside package path: '../library/lib.zig'. I can take care of this with a symlink, but curious as to why the relative path doesn't work.
<donaldallen> I should add that the relative path is valid and the symlink does work.
<andrewrk> donaldallen, this is in preparation for package manager. the best way to deal with this is not with a symlink but by setting the package root dir explicitly. --main-pkg-path
<andrewrk> a symlink introduces a system dependency into your project, and one of zig's main goals is to reduce system dependencies
<donaldallen> Ok, thnx.
<andrewrk> donaldallen, if it helps, the default main package path is the cwd from where zig is run
<donaldallen> I've got a directory for the whole project, with subdirs for each component, including the library. This occurred in building one of the components. Making the --main-pkg-path the project directory should fix this. I'll let you know if not.
<andrewrk> donaldallen, another way to solve this would be in your build script using addPackagePath. you can use this to create arbitrary mappings for use with @import
<donaldallen> --main-pkg-path works fine. Still building the old fashioned way, with a makefile, but switching to the build system is high on the agenda.
waleee-cl has joined #zig
<andrewrk> oh, the cli version of addPackagePath is --pkg-begin [name] [path] and --pkg-end
<andrewrk> the build system is still invoking the CLI
<donaldallen> Thanks for the help. Gotta go ....
donaldallen has left #zig [#zig]
Hirezias has joined #zig
return0e has quit [Remote host closed the connection]
return0e has joined #zig
keegans has joined #zig
<keegans> how can i tell the zig build system to use the Android NDK sysroot and link against the libc ? the farthest i've gotten was some linking errors while looking for crt* stuff
<keegans> looking to build an Android aarch64 executable with zig
<andrewrk> keegans, have you looked at the --libc parameter and `zig libc` command?
<keegans> yes- not certain i fully understand it . i dumped the libc configuration for the default setup and then modified it a bit but ran into some issues , let me give it another try
<andrewrk> keegans, that's all I was asking, if you had tried that, ok
<Yardanico> keegans: hmm, you reminded me, gonna try to build zig in termux on android again
<andrewrk> keegans, zig probably needs some android-specific adjustments to link.cpp for android
<keegans> i'm willing to put in some work to get it going , i will just need a little bit of direction
<keegans> let me get back to the broken state where i was and then i'll work from there
<andrewrk> keegans, it will probably be helpful to look at what a c compiler puts on the linker line when targeting android, and compare to what zig is doing with --verbose-link
<andrewrk> keegans, I'll be here all day :)
<keegans> awesome :D i'll give the verbose link a try
<ceymard> is it normal that `zig translate-c stdio.h` segfaults ?
<ceymard> I suppose not
rifkik has joined #zig
<Yardanico> btw, I'll also test some Zig stuff on an aarch64 android tv box with amlogic s912 (8 cortex a-53 cores + 3gb ram) when it arrives (I'll install linux there though)
<andrewrk> ceymard, segfaults always a bug
<rifkik> 3 More days until 0.5
Hirezias has quit [Ping timeout: 276 seconds]
<keegans> yeah so it looks like it https://gist.github.com/meme/fd5a0add5c32e0401af8765ac9f600d8 compiles against crtbegin_dynamic and crtend_android as well as sets the dynamic-linker to /system/bin/linker64
<keegans> and from what i see with zig it tries to link against gcc_shared and crt1, Scrt etc.
<keegans> so that behaviour just needs to be corrected for android then i should be able to link against the Android NDK libc
<andrewrk> keegans, do you have --verbose-link output from zig?
<keegans> i did and then i lost all my previous work on this
<andrewrk> this output from gcc is good, this will help us solve it
<keegans> just give me a minute and i'll grab it again
<andrewrk> keegans, we can test adjusting the linker line by calling lld directly, and then update link.cpp with the knowledge gained
<_Vi> How do I cast `u64` to `?u64`?
<scientes> _Vi, there is an implicit cast
<Tetralux> (Which means `(?u64)(x)` - because confusing.)
<scientes> ?u64(x), this isn't C
<_Vi> scientes, How do I use std.testing.expectEqual for `?u64` expected values?
<scientes> but that will go away
<scientes> and become @as(?u64, x)
<andrewrk> const x: ?u64 = y;
<_Vi> `(?u64)(x)` - this works.
<rifkik> Which reminds me
<rifkik> I think my SNES emulator code has too much parens
<keegans> so it wrongly links against gcc shared and the gcc_eh lib
<keegans> as well as the wrong crt files
<keegans> i just edited the file to show the link errors as proof
<keegans> ( so refresh the gist )
<Tetralux> scientes: I suspect ?u64(x) will not work.
<andrewrk> keegans, can I see your libc.txt?
<keegans> yeah i'll add it to the gist
<keegans> added.
<keegans> the link crtdir contains crtbegin.o libgcc.a libgcc_real.a
<keegans> yeah i modified the lld command that zig outputs and it links fine when i do the proper android stuff
<andrewrk> keegans, -lgcc is not needed; that's solved by libcompiler_rt.a
<dimenus> does anyone here use arch and have compiled the compiler_rt builtins for arm?
<keegans> it looks like the Android libc was statically compiled into it too
<andrewrk> keegans, I'm pretty sure we can get away without crtbegin_dynamic.o and crtend_android.o as well
<keegans> and it runs with qemu-aarch64
<keegans> ah ?
<andrewrk> yeah that has to do with some stupid constructor/destructor thing that nobody in their right mind uses
<keegans> that was the script i used to link the produced Zig object file
<keegans> sounds good
<Yardanico> btw, is there a simple way to iterate over lines in file? or do I have to open the file, read the data, create a slicestream, and only then get stream of data from that?
<keegans> also when using zig build-exe how do i specify that i'd like a dynamically linked executable , just for future reference?
<andrewrk> Yardanico, did you see readUntilDelimiter functions?
<keegans> because i run this stuff in a chroot so there is really no need for this to be static honestly
<keegans> ( since i ship the libc and android bins in the chroot )
<andrewrk> Yardanico, there isn't a non-allocating one though
<Yardanico> well yeah, basically that's what I used before
<andrewrk> keegans, -dynamic. zig generally tries to make things static where possible though
<keegans> ah i was misled by the description : -dynamic create a shared library (.so; .dll; .dylib)
<andrewrk> yes the description is outdated. that flag also does not have good test coverage for build-exe
<andrewrk> keegans, are you interested in submitting a pull request to link.cpp to make android stuff work?
<keegans> yeah , if that's cool
<andrewrk> yeah if you can describe the testing process; I'd like to try setting up the ndk and running some of the examples myself
<Tetralux> Wait - what does -dynamic actually do then?
<keegans> for sure . i'll get zig built and then hack away at it. i am not clear on exactly how i should get the NDK path from the user , though
<keegans> should there be like a configuration file or another flag in libc.txt ... i am not sure
<keegans> because we also need to request an Android SDK version
<keegans> and only like NDK 19+ is clang-only, so supporting old NDK versions is probably? not easily doable
<andrewrk> keegans, this is where the libc.txt file comes in
<andrewrk> the current fields are not adequate to find all the directories?
<keegans> is it possible for me to pass multiple link directories ?
<keegans> if so then yes i guess you could specify all the paths but it won't be exactly intuitive
<andrewrk> crt_dir and static_crt_dir are both link directories
<andrewrk> if it makes sense to do we can also add fields or adjust the comments on that file
<keegans> yeah i'll play around and let you know what's up
<andrewrk> that file is exactly for this purpose; if it's not correct then it needs to be adjusted to be correct
<rifkik> Should I upgrade my Emulator Code to Master now?, or should I wait until 5.0 stabilises
<andrewrk> master now
<andrewrk> 0.4.0 is dead to me
wootehfoot has joined #zig
hasanyasin has quit [Remote host closed the connection]
hasanyasin has joined #zig
avoidr has joined #zig
owl_000 has quit [Ping timeout: 240 seconds]
hasanyas_ has joined #zig
<keegans> andrewrk: so can i specify multiple include dirs and library dirs with libc.txt ?
_Vi has quit [Ping timeout: 276 seconds]
Hirezias has joined #zig
hasanyas_ has quit [Client Quit]
hasanyasin has quit [Remote host closed the connection]
FireFox317 has joined #zig
telemach has quit [Ping timeout: 265 seconds]
<FireFox317> 6 more PRs merged and we have 1000 closed PRs, would be so nice if we have exactly 1000 PRs closed at the 0.5.0 release ^^
<rifkik> andrewrk, how much do you want to add and stabilise until you can make a 1.0 release?
<FireFox317> rifkik, so much. Just scroll a bit through the open github issue. Especially the accepted proposals and you will see some nice things there
wootehfoot has quit [Read error: Connection reset by peer]
wootehfoot has joined #zig
<keegans> i compiled LLVM with z3 support, and that ultimately breaks the linking phase of Zig because it incorrectly links LLVM ( i.e. : doesnt use pkgconfig )
<keegans> what is the fix for this ? just patch it locally by linking against z3 explicitly in the zig_cpp target link libraries, or actually fixing the llvm linkage in the Cmake
<keegans> for now i have just patched it locally
<companion_cube> wait, llvm uses z3? :s
<keegans> you can optionally enable SMT solving for the clang static analyzer
<keegans> the flag is LLVM_ENABLE_Z3_SOLVER
<companion_cube> oh, static analyzer, right.
<keegans> yeah sorry what i said didnt actually make any sense now that i read it over lol
<andrewrk> keegans, that should work since we use `llvm-config --system-libs` in the build
<andrewrk> can you confirm that `llvm-config --system-libs` has -lz3 for you?
<keegans> ha nope
<keegans> it doesn't
<andrewrk> sounds like an upstream bug
<keegans> yep
<keegans> i'm almost done this android linkage stuff then i'll have to take a look over it to make sure i haven't gone and randomly broken other shit
<andrewrk> keegans, does the NDK come pre-built? (with the .o files and stuff) is it open source?
<keegans> yes and yes
<keegans> the libc is bionic which is also open but a massive pain in the ass to build
<scientes> and sucky
<andrewrk> typical google software
<andrewrk> wow even on the home page for bionic: # This is the biggest mess. The C++ files are ...
<scientes> nobody ever took that libc seriously
<andrewrk> if you write zig for android you might not need libc
<scientes> it was done that way to avoid glibc
<andrewrk> honestly it might be more worth to flesh out our own multi-target libc than to try to ship bionic
<scientes> andrewrk, well some libraries might need a libc
<keegans> yeah in my case i need bionic
<keegans> because i want to dlopen
<scientes> keegans, for what, specifically?
<andrewrk> does zig provide dlopen in its libc yet? let me check
Hirezias has quit [Ping timeout: 246 seconds]
<scientes> keegans, yeah but that is what libhybris does and its a blank hole of wasted time
<keegans> nah libhybris is great
<keegans> like yeah it is garbage but like when it works it is super useful
<andrewrk> hm not yet, but zig's libc will support dlopen eventually
<keegans> we used it to make https://github.com/minecraft-linux/
<keegans> which lets us launch Minecraft Android on Linux
<keegans> hybris is just a copy-paste of Android's linker code and then hacks to fix binary incompatibilties between glibc and bionic
<keegans> so you can load bionic applications on glibc linux
<keegans> i've used it for a many other android natives , too
<keegans> "zig's libc will support dlopen eventually" what do you mean ?
Hirezias has joined #zig
<andrewrk> zig has its own (not fully complete) implementation of libc that works for all targets
<scientes> by dlopen he means loading non-free bionic libraries
<keegans> right so you have to implement all the random garbage that the bionic linker does then too
<scientes> keegans, zig does namespace C symbols which means you can mix and match libcs (although that is not fully tested, and there might be problems that come up)
<scientes> *C names
<scientes> symbols is another namespace
<keegans> ah interesting
<andrewrk> keegans, yeah that's fine, that'll just be part of the arm-linux-android target
<keegans> cool ! i will certainly be using that linker for other things too then ...
<andrewrk> I'm describing vaporware, but the point is it's in scope of the zig project
<keegans> yeah
<keegans> ok with my changes ldd is complaining that it's missing __errno_location
<keegans> hmm
<andrewrk> that sounds like it should be provided by -lc
<keegans> right that doesn't exist on bionic, right
<scientes> ewwww, errno was a massive mistake
<scientes> what a stupid idea
<keegans> no i am saying yeah bionic does not have __errno_location
<andrewrk> keegans, ^ put android-specific logic here
<keegans> ah thx
<andrewrk> @import("builtin").c_abi == .android
<andrewrk> but you do need `_errno` to be a function that returns a pointer to an integer
<keegans> errno is a function in zig what ?
mahmudov has joined #zig
<andrewrk> this is just cross platform abstraction over libc errno
<keegans> ah
<andrewrk> how does errno work in bionic?
<keegans> __errno_location is just &errno on Android iirc
<scientes> that doesn't make any sense
<scientes> you can share globals between shared objects like that
<scientes> that's why you need a function that returns a pointer
<keegans> right so then __errno_location would be emulated with func(){return &errno;} i mean
<keegans> not sure the best way to do this , how do i even get errno as a symbol in Zig
<scientes> keegans, that still doesn't work, as the libc functions wouldn't where where &errno is
<scientes> ohhhhhh, you mean it is a elf global symbol
<keegans> its a relocated symbol , no?
<keegans> yeah
<scientes> yeah I'm not sure we have support for those in zig
<andrewrk> we do
<keegans> i see lib/libc/glibc/fns.txt
<keegans> but this is not glibc
<keegans> ill be back in 5
<scientes> (KEYWORD_export / KEYWORD_extern STRINGLITERAL?)? KEYWORD_threadlocal? VarDecl
<scientes> ahh yes
<andrewrk> extern "c" var errno() c_int; pub fn _errno() *c_int { return &errno; }
<andrewrk> it might need to be specified threadlocal
<andrewrk> which we also support
<Tetralux> Wait - `extern var errno() c_int` is valid syntax?
<Tetralux> A var with parens and a return type is valid syntax?
<andrewrk> typo fixed: extern "c" var errno c_int; pub fn _errno() *c_int { return &errno; }
<andrewrk> typo fixed 2: extern "c" var errno: c_int; pub fn _errno() *c_int { return &errno; }
<Tetralux> Was just gonna say ;P
<Tetralux> That makes more sense.
<scientes> still doesn't have to be assigned
<FireFox317> Yesterday's stream was so cool andrewrk!
<andrewrk> thanks :)
<andrewrk> FireFox317, oh, I just realized I forgot to demo -fstack-report
<FireFox317> Ah regarding the stack size usage with async stuff right?
<andrewrk> right, it helps explain what the frame sizes of async functions are and why
<andrewrk> it answers the question "why is @frameSize(foo) so big?"
utzig has quit [Ping timeout: 276 seconds]
<andrewrk> LemonBoy keeps giving me more release notes chores to do, now I have to talk about how zig supports cross compiling for mipsel-linux-musl
<keegans> /usr/bin/ld: errno: TLS definition in /usr/lib/libc.so.6 section .tbss mismatches non-TLS reference in libuserland.a
<keegans> /usr/bin/ld: /usr/lib/libc.so.6: error adding symbols: bad value
<andrewrk> keegans, did you see <andrewrk> it might need to be specified threadlocal
<keegans> oh
<keegans> no i missed that sorry
<andrewrk> no worries
<andrewrk> keegans, here's a little snippet of 0.5.0 release notes I typed up yesterday: https://imgur.com/WTXwlMl.png
<andrewrk> it's quite a relevant example :)
<keegans> ah , thanks because it was not clear where the heck that threadlocal went
<keegans> as in what position
<keegans> have you considered adding some sort of attribute feature rather than making a keyword for all these things
<keegans> i can also think of a lot of cool things i could do with attributes and compile time reflection ...
<keegans> sure but i mean i can have my own annotations as an end user
<Tetralux> Like `annotate(XXX)`
<keegans> yeah my thinking was i can mark really anything , function or struct with an annotation that has an arbitrary name and then i can pass whatever comptime stuff i want to it as well
<keegans> and noinline, threadlocal, and all this calling convention stuff can also just be an annotation
<andrewrk> that's a good proposal
<keegans> i will think about it a bit more and then write something up
<keegans> anyway back to what i was doing on Android -- why can i not have a top-level compile time if in linux.zig
<keegans> it is angry because it says invalid token if and i am unclear as to whats up
<keegans> or how i should implement this checking for ABI
<andrewrk> you can have top level compile time
<andrewrk> happy to help if you show the output
<mq32> andrewrk, cool thing pro annotations: you could comptime the argument (so changing calling convention by comptime computations)
<keegans> sure , thanks one sec
<andrewrk> keegans, I suggest to do this: https://clbin.com/4J5a1
<keegans> yeah i wouldn't have been able to dream that up on my own
<keegans> thx
<andrewrk> files are just structs
<keegans> zig/lib/std/os/darwin.zig:7:5: error: import of '_errno' overrides existing definition ???
<andrewrk> can I see the full error
<keegans> i will say that the error formatting is annoying
<keegans> i gotta scroll all the way up each time
<andrewrk> keegans, what version of master branch are you working based on?
<keegans> just cloned like an hour ago
<keegans> then started my own branch
<andrewrk> hmm. this looks like something that was fixed by 2c8864f yesterday
<andrewrk> oh lovely I can reproduce this
<andrewrk> the big stack of "referenced here" is a recent problem, that won't stick around forever. it was originally to help with dependency loops, but I took it too far
Ichorio has joined #zig
<andrewrk> keegans, give me a minute I'll fix this
<keegans> thank you
halosghost has quit [Quit: WeeChat 2.6]
<andrewrk> keegans, this has uncovered 2 separate issues, which I am interested in fixing. But not today. So I'm going to do a workaround here for you
<scientes> why does translate C create AstNodes?
<scientes> it seems it would be saner to create ZigType first
<andrewrk> scientes, you're looking at deprecated code. see https://github.com/ziglang/zig/issues/1964
<scientes> oh OK, I just ran into the deprecated code not supporting gcc's vector extensions
<andrewrk> we're trying to move to self-hosted translate-c
<andrewrk> see src-self-hosted/translate_c.zig and `zig translate-c-2`
<scientes> which my patch set supports for creating C header files
<andrewrk> and test/translate_c.zig
wootehfoot has quit [Read error: Connection reset by peer]
<scientes> ahh its in clang.zig
<andrewrk> scientes, that file is synchronized with zig_clang.h and zig_clang.cpp
<scientes> and how do i get @cInclude to use translate-c-2?
<scientes> and i guess in the self-hosted code we could use ZigType without @reify
<scientes> *couldn't use
<andrewrk> scientes, that's not wired up because it's not passing enough tests
<andrewrk> you can see the coverage in test/translate_c.zig
<scientes> ok, guess i'll have to write my benchmark in C
<andrewrk> even in the self-hosted version your question is still applicable
<andrewrk> we're going from C-with-types to zig source
<andrewrk> creating a .zig file, and then that gets loaded and analyzed like normal
<scientes> oh yeah, Zig types are consts so we have to have ZigType there too
<andrewrk> we used to create zig types directly. I'm confident that going straight to source is a better approach, having done it both ways
<scientes> oh ok
<andrewrk> this is better for caching and debugging
<andrewrk> keegans, I'll open an issue for the other thing. It's a bug in Zig. Here's my suggested workaround for you: https://clbin.com/rJRMA
<keegans> thanks
<keegans> ok it seems that this threadlocal approach is not working andrewrk , "lld: error: undefined symbol: __emutls_v.errno"
<keegans> the symbol is referenced from ./main.o:(std.c.linux._errno.getErrno) as expected
<keegans> so the symbol is not being bound to errno but rather __emutls_v.errno which is strange
<keegans> i did not know of this behaviour
<scientes> keegans, you need to use thread_local
<scientes> or whatever the zig keyword is
<andrewrk> I wonder if this is llvm or lld being too clever with the android target
<keegans> scientes: yes it is marked as threadlocal, which is the cause of this problem
<andrewrk> I'm asking in #llvm
<keegans> thanks
philipwhite has joined #zig
<andrewrk> keegans, is it aarch64 or arm? v8? v7?
<keegans> aarch64v8
<andrewrk> keegans, https://godbolt.org/z/N9I5jK note how it changes when you delete `-android` from the -target arg
<keegans> ha
<keegans> so they are doing some hackery
<andrewrk> keegans, can you join #llvm on OFTC?
<keegans> yeah one sec
<keegans> im here
<keegans> missed the context though
<keegans> so if i remove the threadlocal i now have `lld: error: undefined symbol: errno` what
<andrewrk> the symbol might be named something else, such as `_errno`. check the .o file / .a file with objdump
<keegans> oooh
<keegans> yeah it's __errno duh
<andrewrk> that's weird that it's not threadlocal though. how is that supposed to work?
<keegans> yeah good question
<keegans> i will investigate further soon
<keegans> anyway it links now !
<keegans> "./main": error: Android 5.0 and later only support position-independent executables (-fPIE).
<keegans> but it is not a PIE
<keegans> zig is not pie by default when dynamic ?
<andrewrk> keegans, make target_requires_pic return true in target.cpp when target_is_android is true
<keegans> will do thanks
<andrewrk> keegans, we may also want to introduce target_requires_pie (side note: love that function name) and make link.cpp check it for construct_linker_job_elf() and add -pie to the linker line in this case
<keegans> unfortunately it doesnt seem like that fixes it
<keegans> ah
<andrewrk> yeah the pic thing is still a good change to make though
<keegans> true^ and yeah that seems like a good way to go
<keegans> i'll do that
<keegans> what other platforms do i add to target_requires_pie , though ?
<andrewrk> we can talk about -dynamic making things PIE later, but this is still a good thing to do, force it on android
<scientes> yeah android requires pic
<andrewrk> only enable it for android for now
<andrewrk> it's just going to have 1 callsite, in construct_linker_job_elf
<andrewrk> for now
<keegans> :+1:
<keegans> "All your base are belong to us." success!
<andrewrk> keegans, this is good stuff, I think we're going to be able to add a column to the support table for Android after your changes are merged
<keegans> exciting !
<keegans> thank you for your help
<andrewrk> np, looking forward to your patch
<philipwhite> what is the right way to read stdout from a ChildProcess? I'm rather confused by the standard library. running v0.4.0, so maybe there's been some changes, but I imagine not too much.
utzig has joined #zig
telemach has joined #zig
Akuli has quit [Quit: Leaving]
<keegans> so i can no longer produce fully static executables like i could earlier hmm
<keegans> i'll put up the pr but i've gotta fix that before you should merge
<keegans> because it is confusing what libc do i link against anyway
Ichorio has quit [Read error: Connection reset by peer]
Ichorio has joined #zig
<keegans> if i have a project that may only be built for AArch64 android, can i set up my libc.txt in the build.zig somehow ?
Ichorio has quit [Read error: Connection reset by peer]
Ichorio has joined #zig
<keegans> alright andrewrk ready for your review
<keegans> ( no rush i am just letting you know )
FireFox317 has quit [Ping timeout: 245 seconds]
<ceymard> mq32: I almost have something showable
<ceymard> complete works for imports, but also somewhat for cImport
<ceymard> the limitation being that it considers that you may have only one
<ceymard> and zig-cache should be at the root of your workspace
<ceymard> I'm also missing a couple of things, and completion is a little wonky ; it ignores for instance ?, * and !
<ceymard> also still no completion on switch () statements
<ceymard> but hey, it's still better than no complete. :)
<ceymard> also I have show symbol in order (ctrl+shift+o), go to definition (f12) and hover
<ceymard> they're all in fairly "alpha" stages though
<ceymard> but I'm getting there
<rifkik> zagSNES just hit 10 stars!
<keegans> now it's 11 :D
Ichorio has quit [Ping timeout: 245 seconds]
waleee-cl has quit [Quit: Connection closed for inactivity]
<ceymard> anyone wants to try out some klunky zig code completion in vscode ?
<rifkik> Sure!
<ceymard> you might have to remove the current extension first
<ceymard> clone it in your extension folder
<ceymard> it's still very much a WIP
<ceymard> but I'm trying to hack together something to wait until the stage 2 compiler is go
<ceymard> cause I can't live without intellisense :(
<ceymard> my life is sad.
<ceymard> oh, make sure zig is in your path or that you set it in the preferences
<ceymard> (also run npm install or yarn in the freshly checkouted folder)
<ceymard> it's js only, no compiled code
<ceymard> but so far it's showing promising results here
Hirezias has quit [Ping timeout: 265 seconds]
<ceymard> I'm interested in feedback
Traviss__ has joined #zig
rifkik has quit []
Traviss__ has quit [Quit: Leaving]