ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
_dev_zero has quit [Remote host closed the connection]
_dev_zero has joined #zig
_dev_zero has quit [Remote host closed the connection]
_dev_zero has joined #zig
Maxxii has joined #zig
cenomla has quit [Quit: cenomla]
dimenus has joined #zig
_dev_zero has quit [Remote host closed the connection]
_dev_zero has joined #zig
puppp has quit [Ping timeout: 240 seconds]
<GitHub158> [zig] andrewrk pushed 1 new commit to master: https://git.io/vFuaL
<GitHub158> zig/master 4f8c26d Andrew Kelley: fix enum sizes too large...
<dimenus> andrewrk: do you have a minute to talk about #538?
<andrewrk> yes
<dimenus> i'm a little confused by what you mean with the msvc compiler driver
<dimenus> msvc doesn't expose an interface to use c1.dll / etc
<andrewrk> dimenus, right, so one of the features of zig is the build system. build.zig and such. and one of the use cases we want to support, is using zig instead of e.g. cmake to build cross platform projects
<andrewrk> even if that project is written in C, and not zig
<dimenus> ok, that sounds good. do you plan on utilizing msvc to compile this code then
<dimenus> rather than llvm?
<dimenus> in this particular test
<dimenus> (still not getting a stack trace in llvm6)
<dimenus> looks like its hitting the panic in debug.zig
<andrewrk> yes, zig build's addCLibrary/addCExecutable is supposed to use msvc on windows
<andrewrk> dimenus, hm I'm not sure why you're not getting stack traces with llvm6 branch. It worked when I tried it
<dimenus> ok, so right now if I take that test and pass --verbose-link cl is what fails
<dimenus> you're using elf, no?
<andrewrk> I'm taking the hello world .zig file, putting @panic("ahhhh") in it, then running zig build-exe test.zig, then running it
<andrewrk> it prompts me to debug with msvc, I click debug, then it shows me a stack trace with source code and everything
<dimenus> i compiled both zig/llvm with CMAKE_BUILD_TYPE=Release
<dimenus> and mine just shuts down
<dimenus> hmm let me test something else
<andrewrk> dimenus, are you talking about debugging the zig compiler itself?
<dimenus> wait a minute
<dimenus> in #538, a valid exe is not produced so in my mind your panic scenario is different
<andrewrk> I thought we were talking about 2 different issues
<dimenus> yeah i think we are
<dimenus> the compiler crashes running the test in #538
<dimenus> but I don't think it's actually a "crash"
<dimenus> i think it's the panic in debug.zig triggering
<andrewrk> I see
<dimenus> i'm going to attempt to replicate the test you had first
<dimenus> just to make sure we're working from the same setup
<andrewrk> you're trying to replicate my @panic("ahhh") and get a stack trace in msvc?
<dimenus> yes
<dimenus> ok, that works which is good
<dimenus> i don't get a prompt to debug, but that's not zig's fault
<dimenus> it produces pdbs and i'm able to debug it
<dimenus> back to 538...
<dimenus> andrewrk: ok it looks like there are a couple things going on here in 538
<dimenus> Windows.h is missing from the generated mathtest.h which makes cl produce a stupid error message
puppp has joined #zig
_dev_zero has quit [Ping timeout: 248 seconds]
_dev_zero has joined #zig
dimenus has quit [Quit: Leaving]
puppp has quit [Ping timeout: 264 seconds]
redj_ has joined #zig
minus has quit [Ping timeout: 248 seconds]
redj has quit [Ping timeout: 248 seconds]
Elronnd has quit [*.net *.split]
Maxxii has quit [Quit: Leaving]
puppp has joined #zig
_whitelogger has joined #zig
minus has joined #zig
puppp has quit [Ping timeout: 240 seconds]
puppp has joined #zig
puppp has quit [Read error: Connection reset by peer]
puppp has joined #zig
PV has quit [Ping timeout: 260 seconds]
puppp has quit [Quit: puppp]
_dev_zero has quit [Remote host closed the connection]
_dev_zero has joined #zig
_dev_zero has quit [Remote host closed the connection]
_dev_zero has joined #zig
_dev_zero has quit [Remote host closed the connection]
_dev_zero has joined #zig
_dev_zero has quit [Remote host closed the connection]
_dev_zero has joined #zig
<ltr_> there is someway to have some kind of autocomplete for zig in vim? just the basic
dimenus has joined #zig
dimenus has quit [Client Quit]
dimenus has joined #zig
redj_ is now known as redj
<ltr_> also, how i can specify the libc-path-dir when doing zig build?
<ltr_> zig cant find libc on ubuntu
dimenus has quit [Ping timeout: 268 seconds]
<ltr_> if i specify the libc dir zig cant find any other lib
<andrewrk> ltr_: did you use the suggested configure line from the readme? It is tested on Ubuntu to find libc
<ltr_> i think ill have to have a clean install of the libraries, i have some kind of mix of versions of different libs
<ltr_> done i had a mess with symlinks
<ltr_> messing with zig + libuv now
<andrewrk> interesting
<andrewrk> ltr_, is it a coincidence that this blog post came out today? https://eli.thegreenplace.net/2017/concurrent-servers-part-4-libuv/
<ltr_> just coincidence, havent saw that post
<ltr_> im a fan of libuv, i like how it resolves concurrence
<ltr_> main.zig:5:22: error: variable of type 'struct_uv_loop_s' not allowed
<ltr_> ill check it
<ltr_> why is not allowed? im defining the variable wrong?
<ltr_> var loop: c.libuv.uv_loop_t = undefined;
<ltr_> declaring*
<ltr_> i have to declare it as a pointer, i dont know why, now it compiles
<ltr_> i think is cos of the way libuv hides "private" members of the C struct with macros
<andrewrk> ltr_, I can improve this error message
<andrewrk> but yes it's because the .h file does not contain the definition of the type; it is opaque
<andrewrk> so you can have a pointer to it but not instantiate it
<ltr_> c.zig:1:19: error: compiler bug: @cImport generated invalid zig code
<ltr_> and a lot of redefinition errors
<andrewrk> ltr_, would you mind reporting that as an issue? I'll have a look after work
<ltr_> ofc
<ltr_> i think is the way libuv trys to do some kind of OOP with C macro magic
<ltr_> where did you find that blog post?
<ltr_> HNA?
<ltr_> HN*
<andrewrk> I subscribe to the author's blog
<andrewrk> so I get an email when he makes a new one
<ltr_> hey andrewrk i have noticed that you like sound, hehe is there a good read on the subject of generating sounds+formats+filters+synths+code, i dont know the jargon so i dont know what to look for
<andrewrk> I don't know of a good introductory reading, but maybe a DSP course on coursera
<ltr_> how for example impulse tracker , i love that piece of software, ill like to know how it works
<ltr_> after lunch ill file the issue
<ltr_> ill look into that course
<andrewrk> it's really difficult. I have tried to take it multiple times and have not gotten past lesson 2-3ish
<andrewrk> I think I need more discipline
<ltr_> i just want to play with samples generate synths notes with code
<ltr_> ok , lunch time c ya
Guest15604 has joined #zig
dimenus has joined #zig
<GitHub130> [zig] andrewrk pushed 1 new commit to master: https://git.io/vFzAL
<GitHub130> zig/master 7ea669e Andrew Kelley: fix parameter of extern var args not type checked...
<GitHub13> [zig] jfo opened pull request #602: fix typo on darwin lseek (master...pr) https://git.io/vFzAi
Guest15604 has quit [Quit: (/quit)]
<GitHub54> [zig] andrewrk closed pull request #602: fix typo on darwin lseek (master...pr) https://git.io/vFzAi
<GitHub62> [zig] andrewrk pushed 1 new commit to master: https://git.io/vFzxI
<GitHub62> zig/master 52521d5 Jeff Fowler: fix typo on darwin lseek (#602)
<dimenus> andrewrk: for 538, the existing compiler code doesn't produce a valid import lib with exports for MSVC to digest
<dimenus> if you can see the difference if you objdump an import lib created with mingw-clang vs zig
<dimenus> or if you're using msvc, dumpbin
<andrewrk> dimenus, I think there is some misunderstanding because #538 has to do with using msvc's binaries - cl.exe and link.exe - and not using LLVM/clang/LLD
<andrewrk> 538 has nothing to do with zig creating import libs
<dimenus> we invoke lld-link to create the dll first and then cl to compile the full executable
<dimenus> no?
<andrewrk> no, for 538, we only use zig to run build.zig, and we just act as the build system for msvc tools
<andrewrk> llvm/clang/lld don't enter into the picture, except to run build.zig
<dimenus> passing --verbose-link to that build emits an LLD call though
<dimenus> and indeed does produce a dll/lib
<dimenus> zig.exe --build-file build.zig --verbose-link
<andrewrk> that's probably for building build.zig into the `build.exe` executable
<andrewrk> and then build.exe orchestrates calls to msvc's cl.exe and link.exe
<andrewrk> or at least that's what 538 is about
<dimenus> we have to be using llvm at some point though, since we're creating a dll. You're not outputting C code as a backend
<andrewrk> cl.exe and link.exe can create a dll
<dimenus> i know that
<dimenus> my point is that zig needs llvm to output obj files, yes?
<andrewrk> yes
<andrewrk> ok, you're looking at example/shared_library
<dimenus> yes
<andrewrk> it has const exe = b.addCExecutable("test");
<andrewrk> this needs to call cl.exe and link.exe
<andrewrk> and it has const lib = b.addSharedLibrary("mathtest", "mathtest.zig", b.version(1, 0, 0));
<andrewrk> this one is via zig, so it uses llvm/lld
<dimenus> did you think I was looking at the second case?
<dimenus> my bad, for not being explicit about that
<andrewrk> I don't understand your question
<dimenus> anyway the IR emitted by zig is missing 'dllexport' which is required to produce a valid .lib file on windows
<andrewrk> ah I see
<andrewrk> we can add that
<dimenus> what test case were you referring to?
<andrewrk> the same one as you
<dimenus> then how were you saying it doesn't use llvm o.0
<andrewrk> ok I see the confusion
<andrewrk> I forgot that it had both b.addCExecutable and b.addSharedLibrary
<andrewrk> I thought it was all C
<dimenus> ah, that makes sense
<andrewrk> ok what you said makes perfect sense
<andrewrk> my mistake
<dimenus> no worries, we're in an agreement now
<dimenus> also, you are completely write that msbuild INSTALL does update from the source tree
<dimenus> idk how I was getting old files...... maybe not calling install?
<dimenus> **write=right
<dimenus> more coffee is needed
<ltr_> andrewrk: done , issue filled -> https://github.com/zig-lang/zig/issues/603
<andrewrk> thanks ltr_, I'll have a look later today
<ltr_> im finding a way to get arround this, the only thing i can think of is to wrap everything in simple c functions
<ltr_> is the grammar in the documentation up to date?
jfo has joined #zig
<andrewrk> ltr_, I believe so
<andrewrk> you can also use `zig parsec foo.h` where foo.h has #include <uv.h>
<andrewrk> that will print a bunch of declarations, which can be useful for reference
<jfo> andrewrk: maybe another darwin bug...
<jfo> calling `warn("{}", file.getEndPos());`
<jfo> std/os/darwin.zig:131:30: error: expected type 'type', found '&const extern fn(noalias &const u8, noalias &Stat) -> c_int'
<jfo> getting
<jfo> at
<jfo> pub fn fstat(fd: i32, buf: &c.stat) -> usize { errnoWrap(c.fstat(fd, buf)) }
<andrewrk> hi jfo
* jfo waves
<andrewrk> ah. yeah. in C there's a `struct stat` and `stat` function; in Zig we rename the struct to Stat to disambiguate
<andrewrk> jfo, try changing the s to S and see if it fixes it
<jfo> 1 sec
<jfo> ok that leads me to
<jfo> std/c/index.zig:16:42: error: expected type 'type', found '&const extern fn(noalias &const u8, noalias &Stat) -> c_int
<jfo> and then changing case of that gives me
<jfo> std/io.zig:250:25: error: no member named 'Stat' in '/Users/jfo/dogfood/zig/build/lib/zig/std/os/darwin.zig'
<andrewrk> jfo, in std/os/darwin.zig, after `pub const timespec = c.timespec;`, add `pub const Stat = c.Stat;`
<andrewrk> what's going on here is, std/os/* is the non-libc os interface. However, on Darwin, using libc is the os interface.
<andrewrk> so std/os/darwin.zig depends on std/c/* and we expose some things selectively
<andrewrk> but to API users of zig std lib, you go through std/os/* not std/c/*
<jfo> ok almost there.
<jfo> std/c/index.zig:16
<jfo> pub extern "c" fn fstat(fd: c_int, buf: &stat) -> c_int;
<jfo> index.zig:16:42: error: expected type 'type', found '&const extern fn(noalias &const u8, noalias &Stat) -> c_int'
<andrewrk> that stat should also be Stat
<ltr_> thats the output of the parsec on #include <uv.h>
<andrewrk> ltr_, yeah, and you can see how it incorrectly generates `pub const uv_connect_t = struct_uv_connect_s;` twice
<jfo> andrewrk: that leads me to some more ish, let me see if I can unravel it I'll brb ty
<andrewrk> ltr_, it's a bug in parsec.cpp
<ltr_> i can look into it
<andrewrk> great
<ltr_> i really want to deploy a microservice in production here in zig lol
<jfo> andrewrk: oh wait! got it.
<jfo> pr coming
<andrewrk> ltr_, sounds like we need concurrency and networking :)
<andrewrk> ltr_, oh, or libuv like you're doing :)
<jfo> ++ concurrency and networking :)
<andrewrk> jfo, I'm going to be working on those things very soon
<jfo> i i know just throwing in my ++ !
<jfo> :)
<ltr_> exactly
<ltr_> here in my job they are spending a lot of money in AWS cos of bloated crap like spring boot to do simple selects and transform em to json, 150mb just to start the vm.
<ltr_> it is just too painful to watch
<andrewrk> ltr_, if you get something working and your company likes it, see if they want to do a sponsorship with a banner on ziglang.org
<GitHub192> [zig] jfo opened pull request #605: Fix Stat include in darwin land (master...pr) https://git.io/vFgOl
<GitHub87> [zig] andrewrk pushed 1 new commit to master: https://git.io/vFgOR
<GitHub87> zig/master 336d818 Jeff Fowler: Fix Stat include in darwin land (#605)
<GitHub66> [zig] andrewrk closed pull request #605: Fix Stat include in darwin land (master...pr) https://git.io/vFgOl
<jfo> looks like the only discrepency is `st_birthtimespec: struct_timespec`
<andrewrk> jfo, rdev: u64 is wrong
<andrewrk> let me double check it on my mac
<jfo> :+1:
<jfo> bbiab dinner time.
<andrewrk> jfo, I have the same output as you. so I translated the struct incorrectly. so we can use the values for the struct that you obtained just now
jfo has quit [Ping timeout: 260 seconds]
<ltr_> (gdb) p record_decl->isStruct()
<ltr_> Couldn't find method clang::RecordDecl::isStruct
<ltr_> need tips for gdb
<ltr_> to use clang functions
<andrewrk> ltr_, it seems to matter whether you use -> or . correctly
<andrewrk> ltr_, oh, did you compile clang in debug mode?
<ltr_> i think not
<andrewrk> you'll probably have to do that if you want to use gdb usefully
<ltr_> Cannot resolve function decl_name to any overloaded instance
<ltr_> ok it passes twice for some reason on typedefs
<dimenus> andrewrk: so I've broken 538 (the dll creation part) into a minimally reproducible example
<dimenus> and if i do build-lib on mathtest.zig it produces no exported symbols
<dimenus> I found the LLVM function to specify the DLLStorageClass but when I add it, it's now exporting a lot of other symbols as well that I wouldn't expect to exist
<dimenus> ex, w/ clang if i have a math.c file with just add(int x, int y) in it, it produces a dll with one function
<dimenus> where as zig adds mempy, memset, floor, fmod and a lot of others
<andrewrk> this is expected
<dimenus> should i just file a new issue?
<andrewrk> what's going on is that clang is expecting to link with libc, which provides all these functions
<andrewrk> llvm generates calls to these functions
<dimenus> shouldn't we assume if we're creating a dll that we shouldn't explicitly export other symbols that we're not using
<andrewrk> dimenus, when we build a zig executable or library that does not depend on libc, first we build 2 things: compiler-rt.o and builtin.o. then we produce yourliborexe.o and link them all together
<andrewrk> we always must have compiler-rt.o and builtin.o. unless we link with libc, which has all the symbols.
<dimenus> but now the calling application can't link with libc
<dimenus> because we've duplicately defined symbols
<andrewrk> it can, the symbols are private to the library
<dimenus> hmm, then I need to find another flag
jfo has joined #zig
<andrewrk> I know it is possible. worst case scenario, we have to submit a patch to llvm to rename the symbol dependencies it generates, to add a namespace to them. But that should not be necessary
<dimenus> is there a flag on a given function decl if it's 'export' in zig?
<andrewrk> yes, it's the `export` keyword
<dimenus> sorry, not the zig keyword
<dimenus> context has an 'export_visib_mod' enum attached to it
<dimenus> if i knew that a given function was export, I can fix this example
<andrewrk> oh, FnTableEntry::linkage
<andrewrk> anything other than GlobalLinkageIdInternal means that the symbol is exported in the .o file
<dimenus> i used that originally, which was what caused the duplicately defined symbol issue
<dimenus> running another test now
<andrewrk> ideally we would end up with a .dll that did not expose stuff from builtin.o and compiler-rt.o
<dimenus> yep, just exposing add in this case
<ltr_> this is weird, the debugger stops at parsec.cpp:2580 if strcmp((*typename)->list.items, "uv_connect_t") == 0 but if i continue to line 2610, but never reach 2611
<andrewrk> ltr_, in my experience, it's not helpful to use gdb unless everything is compiled in debug mode
<ltr_> damn
<ltr_> its weird cos the second time it reaches that line
<jfo> andrewrk: this seems to do the trick https://gist.github.com/jfo/38a182e586487dbd80d455f2fd7be11f
<jfo> weirdly, if I add ` btim: timespec,` it... doesn't though?
<dimenus> andrewrk: add in the mathtest.lib has the same linkage as memcpy for instance
<dimenus> almost all of the functions defined are Internal/String
<dimenus> **Internal/Strong
<andrewrk> dimenus, maybe we can mark add as dllexport, but memcpy not
<dimenus> that's what i'm trying to do
<dimenus> but there's no identifier that I can see on the fn_table_entry that distinguishes the two
<andrewrk> we don't have the concept of dllexport
<andrewrk> we may need to add it to the language
<jfo> a direct translation with `c_` types looks like https://gist.github.com/jfo/771f4a2435764c9d9cba7ffb48324e48 fwiw
<dimenus> andrewrk, there is another option
<andrewrk> jfo, why did you make ino 16 bits? it looks like 64 to me based on your gist
<dimenus> we generating far more IR than clang in this case since its just a dll
<dimenus> clang just generates the IR for that one function
<andrewrk> what IR?
<dimenus> zig.exe build-obj mathtest.zig --emit llvm-ir
<dimenus> clang only generates IR for the add function where as we output almost 2400 lines
<andrewrk> which one do you think is not necessary?
<dimenus> in this situation, everything except add
<andrewrk> I can explain everything
<andrewrk> the implementation of add, when llvm codegens, emits function calls to builtin.o and compiler-rt.o. so we must have these. Notice that they are separate compile units they can be cached.
<andrewrk> further note that when we solve https://github.com/zig-lang/zig/issues/54 the unused functions get omitted when linking
<andrewrk> we also generate code for panic. if we never call panic, all this code gets deleted when you do --release-fast or --release-safe
<andrewrk> or if the user provides their own panic implementation
<andrewrk> at the end of the day, when compiled with --release-fast, our DLL will be as slim as clang's
<andrewrk> and clang's depends on libc, otherwise they would have the same problem as us
cenomla has joined #zig
<jfo> andrewrk: oh yeah of course. 1 sec
<andrewrk> dimenus, if you use `zig build-obj` you can see it only generate code for the add fn
<andrewrk> then the only thing is the panic implementation, and you can make it generate less code by adding one like this: `pub fn panic(msg: []const u8) -> noreturn { while (true) {} }`
<dimenus> sorry, I'm not getting that behavior
<dimenus> if i call build-obj mathtest.zig --emit llvm-ir
<dimenus> i get 144k worth of IR
<andrewrk> I haven't tried --emit llvm-ir yet. tiehuis added that. try this
<andrewrk> zig build-obj mathtest.zig --verbose-llvm-ir
<dimenus> same thing
<andrewrk> I don't think you added the panic implementation
<andrewrk> also try adding --release-fast
<andrewrk> after that I get a single function, and it's add
<andrewrk> the ir is 47 lines
<dimenus> yep, i do get that
<andrewrk> in fact I don't even need to provide a panic implementation
<andrewrk> --release-fast does it
<andrewrk> the resulting IR is a single add function
<andrewrk> but there is a bunch of debug info, which is good
<andrewrk> I think --emit llvm-ir should do the same thing
jfo has quit [Ping timeout: 260 seconds]
benq has joined #zig
<dimenus> i think we'll want #462 straightened out first before we spend too much time on this
<andrewrk> dimenus, yeah, 462 is high on my priority list
<dimenus> right now a lot of those calls in std are export
<dimenus> when we really just need them to be visible within our dll, not to C
<dimenus> if I "fix" it by assigning ExternalDLLStorageClass, we get more symbol issues
<dimenus> so i think I'll table #538 for now
<andrewrk> I'll try to get 462 implemented soon
<andrewrk> to unblock you
<andrewrk> and I'll play with making a DLL
cenomla has quit [Quit: cenomla]
cenomla has joined #zig
cenomla has quit [Client Quit]
cenomla has joined #zig
<ltr_> andrewrk: i know where the problem can be, im going home now, tomorrow ill be on zig all day
<andrewrk> ltr_, exciting
<andrewrk> good night
cenomla has quit [Quit: cenomla]
dimenus has quit [Ping timeout: 248 seconds]