mikdusan has quit [Read error: Connection reset by peer]
mikdusan has joined #zig
ifreund_ has joined #zig
<noam>
I agree with ifreund on that, implicit coercion to [*:0] could change the length, thus changing the value
<noam>
Implicit casting should never have such an effect
<noam>
[:0] means "a zero indicates the end", but [*:0] means "the *first* zero indicates the end"
<andrewrk>
both [:0] and [*:0] contain the same len if you use the null terminator to find the end
<andrewrk>
however using a null terminated slice where the explicitly stored len and the sentinel-determined len disagree is a smell
<noam>
Not always - I can meaningfully have e.g. a ROM which contains zeroes, which is terminated by EOF also
<g-w1>
eof != 0
<noam>
On $RANDOM_HOBBY_OS it is /shrug
<g-w1>
how can you tell end of file then?
<noam>
It's a poorly designed hobby os! :P
<noam>
(yeah, that's a bad example :P)
wilsonk has joined #zig
<noam>
Data was loaded from C - and is thus null-terminated - but was afterwards truncated, and the length of the sentinel-terminated slice gives the allocation size, allowing easy growth without reallocating
<noam>
Basically, using slice length to hold capacity, and terminating with a sentinel
<g-w1>
interesting
<noam>
... that's probably not a reasonable use case, though
teratorn_ is now known as teratorn
jjido has quit [Quit: Connection closed for inactivity]
<andrewrk>
ifreund, do you remember off the top of your head how `[_]T{a, b}` is represented in AST? specifically the _ part
<andrewrk>
oh I guess it's just a normal type expression
<noam>
One thing Zig absolutely got right: ` = undefined;`
<noam>
> lexer.c:312:54: warning: βhandleβ may be used uninitialized in this function [-Wmaybe-uninitialized]
<noam>
Uninitialized value is *deliberately* uninitialized in branches where it's not needed. This is in hot code, and zero-initializing consumes ~600K instructions total on a decent-sized test
<noam>
So, you know, good work :P
<mikdusan>
that error sounds like it's giving permission to use it uninitialized
<noam>
mikdusan: compiler allows it, but it's the only warning - and I can't just suppress the warning, because in every other case it's given that, it's been correct that there was an issue
<noam>
There's another option I can try,,,
<noam>
... which is even worse, costing 6M instructions total
<noam>
Point is, zig got this right
<noam>
Is there any valid use case for a type expression having side effects?
<noam>
e.g. `foo = fn(u: comptime *u32) bar(u)`, where bar modifies u?
waleee-cl has quit [Quit: Connection closed for inactivity]
<noam>
I didn't mean "is it legal in the language?", I meant "is there any use case for which this ability is actually necessary?"
<noam>
s/necessary/reasonable/
<andrewrk>
oops, thought you were asking a spec question sorry
<noam>
No worries, I ask those often enough that I'd be surprised if you didn't :P
<noam>
andrewrk: if you extract that block into a function and invoke it in the return types of two different functions, and have it return u8 if x > 4, then the return types of functions depends on the compiler's implementation
<noam>
That seems very wrong
<andrewrk>
why does it depend on the compiler's implementation?
<noam>
unless there's a mandated method of determining the order of comptime execution?
<noam>
the function types depends on the order in which the calls are executed
<noam>
I don't think there's any sane way to mandate a specific ordering
<andrewrk>
can you type up the example? I want to understand how the order independency has been violated
<andrewrk>
anyway this example isn't legal - comptime var is not valid at top level
<noam>
You can have a comptime function return a pointer to a local, right?
<andrewrk>
yes
<noam>
or, better phrasing: is there a mechanism that can allow for mutable comptime data being available in a declarative scope?
<noam>
Right, okay
<noam>
just treat this as shorthand for that?
<noam>
or, better phrasing: is there a mechanism that can allow for mutable comptime data being available in a declarative scope to multiple call sites consistently*?
<andrewrk>
I can't treat it as shorthand, you gotta do it
<andrewrk>
no top level comptime var
<noam>
yep
<noam>
Huh, I think that actually answers my question perfectly :)
<noam>
There's no way for a call within a declarative scope to gain access to consistent mutable data, right?
<andrewrk>
comptime vars become immutable when they go out of scope
<noam>
Gotcha, thanks :)
mikdusan1 has joined #zig
<noam>
tl;dr: it's impossible for a type to depend on mutable state in a declarative scope, which is the only case where it would be an issue?
mikdusan has quit [Ping timeout: 268 seconds]
<andrewrk>
there is no mutable state in a declarative scope
linear_cannon has quit [Read error: Connection reset by peer]
<plumm>
is there a way to set an environment variable
<andrewrk>
there is when you spawn a child process. if you want to do it for third party code you have to know how they are accessing the env var. e.g. if it is via libc then you need to use a libc function
<plumm>
interesting. thanks
<plumm>
I was looking for a way to make it so I didn't have to remember to use the system linker hack for mac os
bitmapper has quit [Quit: Connection closed for inactivity]
ur5us__ has quit [Ping timeout: 258 seconds]
sord937 has joined #zig
<andrewrk>
I hope Jakub's work will make that feature go away entirely soon
<andrewrk>
I will make sure to check your project before flipping the switch
<deb303>
Honestly, I was just curious how I'd implement something like this in Zig
<deb303>
Pretty much just for experimentation
<ikskuh>
ah, okay
<ikskuh>
andrewrk: are you open for a "@uniqueTypeInt(type) comptime_int" builtin?
<ifreund>
ikskuh: I think that is a question that is better asked as a proposal with motivating use-cases
<ikskuh>
i want to make sure it's worth a proposal :D
<ifreund>
I feel like that's up to what you think not what andrew thinks
<deb303>
I think probably a lot that could be done with Any could also be done in alternative ways
<deb303>
But I felt like it might be good for rapid prototyping
dingenskirchen has quit [Quit: ZNC 1.8.1 - https://znc.in]
cole-h has joined #zig
<TheLemonMan>
ifreund, can you remind me if there's a way (beside adding a bogus // at the end of the line) for telling zig fmt not to collapse an if-else chain on a single line?
dingenskirchen has joined #zig
<plumm>
deb303 what is the use case of any over usize union tho
<ifreund>
TheLemonMan: add a newline after the condition
<ikskuh>
plumm: what is a usize union?
<plumm>
@ptrToInt will give you an address
<ikskuh>
that's not an "std::any", but just a pointer ;)
<plumm>
thats why I said union
<plumm>
you use a union to tag a type on to it
<ikskuh>
and the union does what?
<ikskuh>
even then, it's just a pointer, not a value
<ikskuh>
std::any *stores* any value
<ikskuh>
not a reference
<deb303>
Well, imagine you do not want to restrict yourself to a fixed number of cases
<TheLemonMan>
ifreund, hmm, I wanted something like `if (foo) X\nelse if (bar) Y\nelse Z` but I'm afraid this is not supported (nor it was in the past, if my memory isn't failing me)
<ifreund>
no it isn't supported. It could be if we wanted to though
frmdstryr has joined #zig
<deb303>
plumm: I think a good example would be something Go's error type where you can cast to a more specific type
<ifreund>
though having 3 separate ways to format the thing depending on where you place the line break if any might be confusing
<TheLemonMan>
mikdusan, that explains everything, thank you
<TheLemonMan>
the next question is what the hell is wrong with the Drone CI
<deb303>
For example you have two libraries with functions who need to either return float or string, then you'd need to create two unions structures if the libraries do not know about each other
<deb303>
And you need to handle the wrapping and unwrapping between them
<TheLemonMan>
I can't reproduce the deadlock on any other aarch64 machine
<deb303>
Just returning a float | string seems much easier
<deb303>
Then you can use something like switch, to switch on the type
<mikdusan>
but you can get deadlock on there? I think yesterday I saw you had a 1+ day old process running, was it deadlocked?
<deb303>
I guess the main advantage I see is that it's anonymous
<TheLemonMan>
let me check
<TheLemonMan>
nope, you probably found my looong running git bisect section on LLVM heh
<mikdusan>
ah
<deb303>
It's also more general, you can express errors with these unions so you don't need any special error type anymore
<TheLemonMan>
last time something similar happened it was due to some locking problem in the compiler cache
<TheLemonMan>
but from the logs I can't understand if the tests lock up or it's the compiler's fault
<mikdusan>
everytime I see logs on drone, I think "where's the rest of it"
<mikdusan>
failure logs
<deb303>
You could just define for your library something like const LibraryError = IOError | SizeError | NotFoundError;
<deb303>
And then let's say someone uses your library and wants to return his own errors, he simply could define his own error type liks so
<ifreund>
you can do the exact same thing with zig error sets
<deb303>
Yeah, you can do that but how do you handle following:
<plumm>
tfw you build llvm13 instead of 12
<deb303>
Imagine I want to return additional data with FileNotFound, but each library has its own idea what this data is
<deb303>
You could use an out parameter, but I think that's not fully ergonomic
<deb303>
And you have the benefit that if you'd put them in an union you could handle both cases of each library
<mikdusan>
hmmm... is there a linux command to grab a stack trace for running proc?
<ifreund>
mikdusan: gdb -p, then bt
<deb303>
Or maybe I'm misunderstanding something about Zig's error sets
<mikdusan>
we could loop that in a background script against `zig build test` inside drone's script
<mikdusan>
every minute should suffice
<plumm>
deb303 why arent out params ergonomic?
<deb303>
Because you need to remember that the parameter is an out parameter, and you have one additional parameter at least
<companion_cube>
plumm: you can't nest function calls
<companion_cube>
and you need intermediate variables
<deb303>
What if you want to return associated data with multiple errors? I feel like associating data with an error is much simpler
<plumm>
just behave like mac os apis and dont return associated data
<TheLemonMan>
mikdusan, that's a nice idea
<mikdusan>
gdb complains and wants root before attaching. arg.
<mikdusan>
and there's a /proc/PID/stack that can be cat'd but again, must be root
teratorn__ is now known as teratorn
<mikdusan>
same with /proc/PID/task/TID/stack - must be root
<TheLemonMan>
and I guess core dumps are disabled inside Drone's containers
<TheLemonMan>
otherwise you could just run everything using `timeout` and have it kill the child process and output a core dump after a while
<TheLemonMan>
and then exfiltrate it somehow or run gdb locally
waleee-cl has quit [Quit: Connection closed for inactivity]
<ifreund>
can you not just run the whole test in gdb?
<mikdusan>
hmm there is also the complication of which proc is the problem. is it `zig build` or is it an artifact executable that is launched by it
<mikdusan>
and right on queue, drone decides to take a hiatus from starting pipelines
<plumm>
mikdusan are you using brew llvm or your own checkout? I compile clang/lld/llvm but am unsure about how to augment that to the zig cmake
<TheLemonMan>
wild idea, run it under strace
<mikdusan>
heheh
<mikdusan>
plumm: I roll my own llvm
<plumm>
do you use DCMAKE_PREFIX_PATH?
<TheLemonMan>
mikdusan, I've just noticed your commit 300ebbd56090d7c96478293354e24c0f3341ec85 was reverted when all the feature files were regenerated using update_cpu_features.zig
<TheLemonMan>
you probably want to add it to powerpc's feature_overrides list (and regenerate the file if you have a llvm-tablegen at hand)
<TheLemonMan>
we should default to "ppc" for PowerPC targets
<mikdusan>
yeah I'll try .omit=true and see if zig cc is happy
bitmapper has joined #zig
<mikdusan>
plumm: btw `-DCMAKE_FIND_USE_CMAKE_SYSTEM_PATH=OFF` is the trick to use cmake from brew or macports, but instructs cmake to NOT search the brew or macports tree for libraries,
<mikdusan>
this is what really messes things up on macos. so disabling that, but then you need to make sure SDKROOT is set
<mikdusan>
or scratch last part. SDKROOT is orthogonal
pretty_dumm_guy has joined #zig
<plumm>
mikdusan I had to jump into a work meeting, I will try to compile zig now
<plumm>
I'm still somehow missing CLANG_INCLUDE_DIRS and friends, womp
<mikdusan>
plumm: on re-reading your CMAKE_PREFIX_PATH question. yes, I use it during zig cmake, setting it to the llvm tree
<plumm>
mikdusan llvm tree?
<plumm>
(there are so many folders named llvm.. D:)
<mikdusan>
llvm install location
braket7 has quit [Quit: Ping timeout (120 seconds)]
<plumm>
{CLANG,LLVM,LLD}_INCLUDE_DIRS all notfound when setting prefix path to the `_build`... folder from your llvm install script
braket has joined #zig
marijnfs has joined #zig
<marijnfs>
i'm using libnng for networking, but thinking of going pure zig. What is the state of the tcp functionality? Is it considered quite stable?
<andrewrk>
mikdusan, I have a feeling if we manage to get a stack trace on that drone ci hang it will be enough to solve it
<mikdusan>
oh so drone runs as root. yay.
<mikdusan>
and it looks like 128 GB RAM
frmdstryr has quit [Ping timeout: 252 seconds]
<TheLemonMan>
barely enough to build stage1 heh
<mikdusan>
zing!
<TheLemonMan>
andrewrk, #8542 is ready to go, the freebsd failure is unrelated and unininteresting as that's another x86_64 build
<andrewrk>
nice work!
<TheLemonMan>
brb, rebuilding stage1
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<mikdusan>
hahah
<andrewrk>
TheLemonMan, I'm excited for you to see how much more memory efficient stage2 is :)
<andrewrk>
it's pretty drastic
teratorn_ has joined #zig
<ikskuh>
marijnfs: using zig-network, you can get cross-platform networking with tcp and udp
<companion_cube>
isn't Thelemonman redoing his own compiler anyway? Zyg?
<ikskuh>
nope, LemonMan is a top-contributor on zig :)
<marijnfs>
the stuff in std/net.zig has less functionality i gather?
<marijnfs>
i indeed see no udp
<ikskuh>
yep
lemur has joined #zig
<ikskuh>
(MasterQ32 == ikskuh == xq)
<marijnfs>
did you write it?
<marijnfs>
i see, cool
<ikskuh>
not everything
Akuli has joined #zig
<marijnfs>
it has async examples i see, looks cool
<ikskuh>
Alex Nask has also their code in there
<companion_cube>
ah my bad
<marijnfs>
ikskuh: it's for peer to peer, so I also like to retrieve apparent ip's for incoming connections, i guess it has that?
lemur has quit [Remote host closed the connection]
<plumm>
I want to be the first one to compile zig on an ipad
<ikskuh>
marijnfs: yep
<marijnfs>
neat, yeah this looks like it could be a good fit
l1x has quit [Quit: Connection closed for inactivity]
<marijnfs>
if a connection breaks down, how do I detect that quickly? Or will simply the next send return an error
<ikskuh>
next send will error
<ikskuh>
you can also use poll
<companion_cube>
you could send heartbeats
<ikskuh>
we have a cross-platform impl for it
<ikskuh>
that allows polling for errors / closing
lemur has joined #zig
lemur has quit [Client Quit]
<marijnfs>
ikskuh: that could be good too, no callbacks?
<ikskuh>
callbacks? those need an event loop and allocation
<marijnfs>
yeah that works. in an event loop, you don't want to poll too often, but it could have some sleep i guess
<marijnfs>
have you tried udp hole punching with your code?
<ikskuh>
no
<ikskuh>
but that's not necessary
<ikskuh>
udp hole punching is not a problem of the library
TheLemonMan has joined #zig
zie has joined #zig
<noam>
companion_cube: oh no, how awful, you mixed up two people on the internet! The horror!
<companion_cube>
I know, I'm terrible
<companion_cube>
sorry M. Chomsky :(
<noam>
... isn't chomsky, like, 80?
<companion_cube>
:D
<companion_cube>
probably
<noam>
I must've really let myself go if internet people think I'm 80! ;)
<marijnfs>
ikskuh: true, just wondering
<TheLemonMan>
I'll make my own compiler with blackjack and hookers
<noam>
ewwwwww, gross!
<noam>
blackjack is such an average game
<noam>
and you want to embed it in a *compiler*?
<noam>
What, do you have to win a game of chance or your code gets miscompiled?
<plumm>
so a normal computer?
<noam>
I mean, normally there's an element of skill involved!
<noam>
not always a particularly strong element
<plumm>
mikdusan in the llvm build folder, inside the include folder, there is only llvm, not folders for clang, lld, etc like how brew llvm@11 is setup (which works)
<mikdusan>
plumm: that cmake line to build llvm assumes you have llvm-project (monoproject) checked out. it has sources for llvm/clang/lld . building against that, and install will get you all 3
<plumm>
ah i was missing the install
<plumm>
shameful
<mikdusan>
alrighty I hacked test_runner.zig and added an "OOT killer" which sends SEGV to self after 10 mins which should let gdb backtrace the core
moka has joined #zig
vazub[m] has quit [Ping timeout: 245 seconds]
Sumera[m] has quit [Ping timeout: 245 seconds]
suhashebbar[m] has quit [Ping timeout: 245 seconds]
mokafolio has quit [Ping timeout: 260 seconds]
moka is now known as mokafolio
vazub[m] has joined #zig
Sumera[m] has joined #zig
suhashebbar[m] has joined #zig
<mikdusan>
hell... maybe zig's segv handler will do the trick too
nefix has joined #zig
dimenus has joined #zig
<andrewrk>
that's interesting
<andrewrk>
really appreciate you looking into this mikdusan - my motivation was flagging on this one
<g-w1>
andrewrk: thanks for fixing up the try stuff
<andrewrk>
np
<andrewrk>
I'm on defers now. hard problem
<andrewrk>
defer and errdefer are entirely implemented in AstGen
<nefix>
hello! I'm trying to use a C library using zig. In the headers of this library, there's an anonymous enumeration, with some type definitions. Is there a way to import this anonymous enumeration into a (zig) non-anonymous enum? Something like "every type that starts with "XXX"? Am I thinking this wrongly? Thanks! :)
<andrewrk>
nefix, are you using @cImport ?
<nefix>
yep!
<nefix>
And @cInclude inside it
<andrewrk>
I believe it will provide pub const declarations for anonymous enum tags that you can use, at the top level
<andrewrk>
or are you trying to get ahold of the type itself?
<nefix>
yeah, I can access to each item inside that anonymous enum, but I want to throw them inside a common type
<nefix>
I'm new to Zig, C and low level languages, so maybe I'm not explaining myself correctly or it doesn't make sense
<andrewrk>
generally, you will have the most success if you make your zig code that uses @cImport look like the C code that would use that same header file
<nefix>
I want to do something like `const Channel = struct{ id: c.CHANNEL };`, and the enum types are `c.CHANNEL_XXX`
<andrewrk>
with respect to the enum in question
<andrewrk>
I see, so this is simply a problem of accessing the enum typ.e
<nefix>
yes, but the enum itself is anonymous, so there's no enum type
<andrewrk>
how would you access the anonymous enum in C code?
<nefix>
I wouldn't access the enum itself, but it's contents, but I want to create a common type with all the enum contents
<g-w1>
maybe just use some sort of int? you can also just massage the translated-c
<g-w1>
translate-c header.h > thing.zig
<g-w1>
edit thing.zig
<nefix>
Yeah, I guess I'll end up using int. Though items in the imported C are using c_int. How should I translate between those types?
<g-w1>
@intCast(
<nefix>
thanks for all the help!! :D
<nefix>
oh, another question! How can I write to binary? And how can I select the endianess? Thanks again! :)
<g-w1>
wdym write to binary?
<g-w1>
a file, an array?
<andrewrk>
put this with your imports: `const native_endian = std.Target.current.cpu.arch.endian();`
<andrewrk>
you will have to figure it out yourself for now
<nefix>
oh :(. May I ask why?
<andrewrk>
std lib is still unstable and experimental while we focus on the compiler
<nefix>
Oh. I'll see what I can do
<nefix>
Thanks again! :)
<andrewrk>
happy hacking
<nefix>
I doubt I'll make it work, but I'll try xDD
<andrewrk>
serialization and deserialization is often an application-specific problem, with general solutions being less than ideal
<nefix>
I'm thinking to use Zig for implementing network protocols, so in every library I'm going to have to use binary serialization and deserialization. Maybe a general interface and being able to implement it with types would be great
<andrewrk>
if it's for a network protocol, all the more reason to stay away from automatic serialization and make your own code carefully
<nefix>
Hmmm maybe I'm too used to high level coding and I'm thinking this all wrong :)
<marijnfs>
nefix: I'm using that serialization as well, it's pretty good
<marijnfs>
i also added optional pointers and alloc based serialization
<nefix>
In reality, the "hard" part for me right now is the Little/Big endian thing, but maybe with the function that g-w1 pointed me out I'll be able to make work
<g-w1>
yeah, those should normalize it
<nefix>
marijnfs: do you have a example on how are you using it?
<nefix>
I see, thanks :)
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<marijnfs>
but basically you just handle the .Optional case and write some u8 to signify the optional part.
dimenus has quit [Read error: Connection reset by peer]
dimenus has joined #zig
<marijnfs>
in cereal, they simply have a portable_buffer that deal with Big\Little endian and swaps the bytes around on the fly
leon-p has quit [Quit: leaving]
<cepheus>
hey, i sorta got zig code running in 3ds userspace
<cepheus>
some hand hacking involved because devkitARM's libctru does not play so nicely with zig's translate-c
xackus has joined #zig
<g-w1>
andrewrk: i suspect the error here is that _ is not allowed in std.fmt.parseInt, should it? https://clbin.com/gKpHY also i can't build stage2-whole-file-astgen so i can't confirm my suspicions
GreaseMonkey has quit [Remote host closed the connection]
<nefix>
Oh, I was just typing "ziglearn doesn't have a chapter on that" thanks :D
<andrewrk>
you can check `@import("builtin").single_threaded` to find out if threads will be available
<nefix>
thanks! :)
<andrewrk>
it is always true for wasm (until thread support gets finalized in the spec)
<nefix>
Would you recommend to have two ways of handling things, using async if it doesn't have multithreading and threads if it does?
<andrewrk>
you can generally write code agnostic to whether I/O is async or blocking
<nefix>
And are Zig programs by default single-threaded?
<barakkl1993>
r
<g-w1>
yes
<andrewrk>
if you use `std.fs.writeFile` for example, it will do the right thing in either context
<nefix>
ok, thanks! I'll check it out
<nefix>
:)
<andrewrk>
nefix, no, by default zig programs will have @import("builtin").single_threaded == false for targets that support threads
<andrewrk>
however if you, or any libraries that you use, don't spawn any threads, then there won't be any threads
<g-w1>
but zig doesn't use threads without you telling it to
<nefix>
ok, that's what I thought! Thanks!
<nefix>
It feels a bit weird to do all those things manually xD
<ikskuh>
you will learn the joys of that :)
<andrewrk>
what language did you use where it spawns threads automatically?
<nefix>
I use Go, and never have done anything related to threading
<nefix>
There are goroutines, but as far as I know they're not threads
<nefix>
There can be multiple goroutines in one thread and multiple threads in a Go program I think? But I'm by no means an expert in this! :)
<andrewrk>
go does not spawn threads or goroutines unless you use `go`
<andrewrk>
if you enable the experimental async I/O in zig it will be the same concurrency model as go, just replace `go` with `async`
<nefix>
experimental == 0.8.0?
<g-w1>
now
<andrewrk>
what is the question?
<ikskuh>
nefix: ou can enable that with "pub const io_mode = .evented;" in the root file i think
<ikskuh>
(not sure, never used it)
teratorn_ is now known as teratorn
_Vi has joined #zig
<_Vi>
Is there already package repository for Zig? How project should specify their dependencies? How should project be structured to be `@import`ed by other developers' projects?
<_Vi>
So in some sense Zig is not finished yet and a package manager and repository is intentionally omitted to prevent proliferation of soon-be-outdated packages?
<g-w1>
i think it can as stage2 will now handle this
xackus_ has quit [Quit: Leaving]
xackus has joined #zig
<andrewrk>
_Vi, yes
tm-exa_ has joined #zig
tm-exa has quit [Remote host closed the connection]
<andrewrk>
g-w1, let's wait to close it until the use case is solved in practice. we're not shipping stage2 yet
<g-w1>
ok, makes sense
<g-w1>
could stage2 be used for headergen in addition to stage1? i think this might work
<g-w1>
once the cbe gets structs and enums and union support
<andrewrk>
not sure what you're asking
<g-w1>
even if stage2 is not shipping, if the cbe is ready for emit-h, could it be used?
<g-w1>
i imagine this will be ready pretty soon
<andrewrk>
how would that work?
Bernstein has quit [Remote host closed the connection]
<andrewrk>
since stage1 does its own semantic analysis, and stage2 cbe depends on stage2 semantic analysis
<g-w1>
oh interesting
<g-w1>
yeah, it wouldn't work
barakkl1993 has quit [Ping timeout: 260 seconds]
marijnfs2 has joined #zig
marijnfs2 has quit [Client Quit]
marijnfs2 has joined #zig
<nefix>
does #include work with `zig translate-c`?
<xackus>
yes
<nefix>
It's throwing me a not found error :/
<nefix>
Also, can I translate a whole directory with .h files?
m4r35n357 has quit [Ping timeout: 240 seconds]
<xackus>
you probably want @cImport for that
m4r35n357 has joined #zig
<nefix>
why? Can't I translate those header files to zig?
<g-w1>
you can
<g-w1>
a little shell goes a long way :P
<xackus>
but if you try to use them in a single zig file there will likely be clashes
<nefix>
Right now I'm running `zig translate-c lib/file.h`, but it's throwing me `lib/other-file.h` file not found
<nefix>
But the other file does exist
kchambers has quit [Quit: WeeChat 3.1]
<xackus>
-I[dir] Add directory to include search path
<nefix>
Oh!! Are there any docs? I couldn't find it anywhere
<xackus>
zig translate-c --help
<andrewrk>
don't think you want to translate a whole directory of .h files. what you want is 1 @cImport with multiple @cInclude statements
<nefix>
I thought I needed to do the translate, because when I try to build for wasm32-wasi, it throws a "Unsupported architecture" and "gnu/stubs-32.h file not found" errors
<nefix>
^ (using cImport)
<xackus>
cImport and translate-c use the same code internally
<nefix>
then is my system missing some libraries to cross compile?
mikdusan has joined #zig
<xackus>
what C library are you trying to use?
<nefix>
spice-protocol
<xackus>
maybe it just doesn't support wasm
<nefix>
It's only .h files
<g-w1>
put the -target in the translate-c, youll get the same error
<g-w1>
you probably need a wasm libc
<g-w1>
there was a recent issue iirc
<nefix>
`stubs.h:7:11: 'gnu/stubs-32.h' file not found`
<nefix>
Now I can run the translate-c command, but if I try to build-exe, throws a libunwind "Unsupported architecture" error
a_chou has joined #zig
<xackus>
mikdusan I got to the point where translate-c and run-translated-c tests pass
<xackus>
but only when I link against debug llvm+clang+lld
<andrewrk>
what are you working on xackus?
<xackus>
when I link against release zig0 still segfaults
<xackus>
I want to try out a new clang api for expanding macros
<andrewrk>
ah
<andrewrk>
any reason to believe it will be more useful than our own macro parsing?
<xackus>
if we depend on clang anyway why not use it?
<andrewrk>
if it's not better
<xackus>
I don't know yet, I just got my branch to work at all
<xackus>
but only with debug llvm so it's πππ
sm2n_ has joined #zig
sm2n has quit [Ping timeout: 252 seconds]
SLWW_ has joined #zig
sm2n has joined #zig
<mikdusan>
xackus: just did a pull on your branch; against release llvm13, I get segfault using zig0 to make zig1.o; and using release+assert == NO SEGFAULT
<mikdusan>
wtf
sm2n_ has quit [Ping timeout: 246 seconds]
<mikdusan>
to clarify: I am always building "zig" with cmake Debug. it's just llvm that is changing from release or release+assert
<xackus>
my zig is debug as well
<mikdusan>
re-ran first case again, and died. this is on macos and strange on linux you get same behavior
<mikdusan>
btw, can you check your dmesg log, just to rule out OOM killer on your end?
<xackus>
nope, it's not oomkiller
a_chou has quit [Quit: a_chou]
* mikdusan
trying a llvm+debug build
<marijnfs2>
i'm getting error.WouldBlock, when does that happen?
eudoxus99 has joined #zig
eudoxus99 has quit [Client Quit]
<mikdusan>
xackus: llvm+debug (which defaults to +assert) doesn't segfault for me either. I suppose it may be possible to do a debug build and disable assert. this is nuts