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/
klltkr has quit [Ping timeout: 258 seconds]
<gamester> How will intellisense-like tooling work with lazy top level analysis? When you're writing a new function you'd want it analyzed. Maybe the function/declaration that you're editing would be analyzed regardless?
daex has quit [Ping timeout: 245 seconds]
daex has joined #zig
<gamester> or you could always do _ = functionName; before writing it
<gamester> My plan: Create a simple LSP server that maintains a replica of my codebase..in an in-memory filesystem. LSP client (vim) sends non-saved changes to my LSP server. LSP server 'writes' to disk (in-memory). LSP server invokes compiler and parses error output, sends as diagnostics to client. No I only use terminal to compile and run, not check for errors.
<gamester> So I get so see all compile errors in-line, but I don't get code completion which I don't care about.
<gamester> This is a very, very simple and yet non-hacky way to get intellisense-like diagnostics without changing the compiler. I'm going for it.
<gamester> The compiler will be invoked on each semicolon. If LSP client sends changes that don't end in a semicolon, the LSP server does not compile. Something like that.
<andrewrk> tralamazza, that's union initialization syntax: https://ziglang.org/documentation/master/#union
<andrewrk> builtin.Arch { .thumb = v7m}
<scientes> yeah there are problems with those unions, i need to look at how do do matches against those
<scientes> (test_target.os == builtin.os and test_target.arch == builtin.arch)
<scientes> access of inactive union field
<scientes> is that really always an error?
<scientes> oh i see > This safety is not available for extern or packed unions.
<scientes> /home/shawn/git/zig/test/tests.zig:177:78: error: operator not allowed for type 'builtin.Arch'
daex has quit [Remote host closed the connection]
daex has joined #zig
_whitelogger has joined #zig
_whitelogger has joined #zig
curtisf has quit [Quit: Page closed]
<tralamazza> builtin.Arch { .thumb = .v7m } seems to make the compier happy, but I get a build: compiler_rt.zig:256:55: error: accessing union field 'arm' while field 'thumb' is set
<tralamazza> error*
<gonz_> andrewrk: You deserve it. Keep up the excellent work and just stay on mission and we'll all be better off for it. Most of the reason I'm having fun getting back to low-level-ish programming after 11/12 years away from it is because of zig.
tdl7rt has joined #zig
daex has quit [Quit: /me 's znc kicks the bucket]
daex has joined #zig
ltriant has quit [Quit: leaving]
SimonNa has quit [Remote host closed the connection]
kristoff_it has joined #zig
marijnfs has joined #zig
hio has joined #zig
kristoff_it has quit [Ping timeout: 272 seconds]
<meowray> gamester: it is difficult to *just* analyze the current function you are editing.. clang analyzes the whole file after preprocessing (minus preamble)
kristoff_it has joined #zig
daex has quit [Ping timeout: 245 seconds]
daex has joined #zig
tdl7rt has quit [Ping timeout: 256 seconds]
avoidr has joined #zig
_whitelogger has joined #zig
Tetralux has quit [Quit: Page closed]
Tetralux has joined #zig
allan0 has quit [Quit: no]
rappet has quit [Remote host closed the connection]
rappet has joined #zig
allan0 has joined #zig
halosghost has joined #zig
<andrewrk> tralamazza, hmm let me try to reproduce this
<andrewrk> tralamazza, what version of zig are you on? I can't reproduce this problem
SimonNa has joined #zig
Akuli has joined #zig
cyanmide has quit [Quit: leaving]
cyanmide has joined #zig
porky11 has joined #zig
<tralamazza> andrewrk: 0.4
<tralamazza> I should try master with that extern fix
<tralamazza> just got back from work, I can zig for a bit
vexu has joined #zig
wootehfoot has joined #zig
<daurnimator> welp, the wikipedia page got moved to "Draft" section
<daurnimator> if anyone wants to add some extra content in there; especially anything sourceable, then we can try and get it moved back into place
wilsonk has quit [Ping timeout: 245 seconds]
wilsonk has joined #zig
<tralamazza> andrewrk: yeah I don't get that error on master
<andrewrk> I would suggest using master at this point. zig is still so young that it's a big difference
<andrewrk> note that we don't even have bug fix releases yet - everything is happening on master branch
wilsonk has quit [Ping timeout: 258 seconds]
<daurnimator> yeah 0.4.0 -> master has quite some changes now
heitzmann has quit [Quit: WeeChat 2.5]
reaysawa has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
very-mediocre has joined #zig
Akuli has quit [Quit: Leaving]
Ichorio_ has joined #zig
wilsonk__ has joined #zig
<tralamazza> is it possible to pass arguments to the linker?
<andrewrk> tralamazza, what are you trying to do? maybe there's a better solution than passing args to the linker
<andrewrk> gonz_, glad to hear it! are you working on a project in particular and is it open source?
<gamester> I'm working on parsing compile errors for my LSP server. Redirecting the compiler's stderr to a file I no longer see the section of source code + the caret pointing to the error location. How does this work? Is that a terminal feature?
<andrewrk> gamester, this is controlled by the --color flag. the default option is "auto" which means it checks if stderr is a terminal or not
<andrewrk> the carot and source line of code is redundant information; when processing compile errors one should ignore them anyway, so I think that behavior is actually what you want
<andrewrk> *caret
<gamester> yes, it is
<tralamazza> andrewrk: working on a minimal arm embedded example, trying to do all in zig
<tralamazza> settings up the vector table and having weak symbols for the handlers for instance
<andrewrk> neat!
<tralamazza> s/settings/setting
<andrewrk> I think zig will work well for this use case, although you will probably hit some snags (that we can hopefully get fixed for you)
<tralamazza> great
<tralamazza> i know the arm side of things, zig not so much :s
<andrewrk> that makes our skill sets complementary :)
<daurnimator> tralamazza: that's good. we need arm experts :)
<tralamazza> dont worry, i am an expert at nothing ;)
<tralamazza> so to have something visible to the linker, it has to be declared as "export", which i take it's a strong linkage
<andrewrk> tralamazza, would it make sense to have "thumb" listed here? or does it make sense for it to be part of the "arm 32-bit" target as it currently stands? https://ziglang.org/#Support-Table
<tralamazza> I am trying to set a weak linkage with @export
<tralamazza> do you have an example of that working?
<andrewrk> tralamazza, yes, first have a look at https://ziglang.org/documentation/master/#export
<andrewrk> actually that example is pretty decent
<andrewrk> enum literals make that linkage argument less cumbersome
<andrewrk> you can just put `.Weak`
<tralamazza> hm yah so arm is a bit silly, thumb and arm are instruction sets, they can be executed and mixed together in the same binary
<tralamazza> I mostly use thumb since it's smaller
<daurnimator> as long as your processor supports both (which not all do)
<andrewrk> hmmm
<daurnimator> and IIRC some instructions only exist in one or the other modes
<andrewrk> I feel like if I had more experience with this, I might organize things a bit differently
<scientes> thumb can do everything since armv7
<andrewrk> but I don't have a good enough intuition for it yet
<tralamazza> it's really the armv that dictates core instruction set
<tralamazza> now everything is extra confusing with cortex-m33 and the security stuff
<gamester> andrewrk: are newlines always \n?
<gamester> in error messages
<scientes> gamester, yes
<scientes> error messages, no idea
<daurnimator> scientes: yeah and I think cortex-m devices *only* support thumb2?
<scientes> daurnimator, yeah all the -m cpus
<scientes> thats the -M instruction set
<daurnimator> i.e. old devices you must use non-thumb. -m cpus you must use thumb2. other devices support both
<scientes> and ARMv8-M is 32-bit only as well
<tralamazza> andrewrk: I guess the question is, if I @export("Foo", Bar, .Weak) can I make Foo visible as a symbol inside the same .zig?
<scientes> why not just call it as Bar tralamazza ?
<tralamazza> how do I position them in a vector table?
<scientes> functions are function pointers until you call them
<scientes> you just have to get the type signature right
<daurnimator> scientes: I think the question is more: how do you get the linker to place them at a specified address?
<daurnimator> or am I misinterpreting things
<scientes> linkers only support that for _start
<scientes> .Weak certainly is not that
* scientes read the scrollback
<daurnimator> scientes: a linker script for a freestanding device can have all kinds of offsets
FireFox317 has joined #zig
<tralamazza> I probably didn't explain well
<scientes> ahh you mean a manual vtable, rather than just a zig vtable
<scientes> I mean if you only need the vtable at a certain place you could probably do this all in zig, but maybe some additional stuff to support linker scripts
<tralamazza> if by vtable you mean a vector table =P
<scientes> i thought you meant function table
<FireFox317> tralamazza: I solved that by making a section in the linker table for the vector table. And then using an array of unions, where one type in the union is a function pointer and the other value is an integer
<scientes> function pointer table
<tralamazza> FireFox317: did you compute the top of the stack in the linker script too?
<tralamazza> right now I have an array of functions, and i have a horrible cast for the top of the stack addr
<tralamazza> thinking of doing a struct instead
<scientes> tralamazza, @export() lets the linker handle it, but extern will make it follow the C abi, and you can write your own dynamic linker if you want
<scientes> but I'm going past my own experience here
<daurnimator> tralamazza: would a solution be to export the vector table as its own section; and then from a linker script put it at the right location?
<scientes> ^^yeah that is what i was suggesting
<scientes> but you said it better
<tralamazza> that is what we/I do
<tralamazza> export const vectors linksection(".vectors") = [_]?Isr {...
<scientes> but for arm you don't need an indirect vtable, you can jump directly
<tralamazza> and the script has .vectors : { etc
<daurnimator> tralamazza: btw make sure you mark it 'extern'
<scientes> so you might just want the linker to handle this stuff
<FireFox317> tralamazza: Yes, the first entry in my vector table (stack pointer) i calculated in the linker script
<tralamazza> FireFox317: thanks
<daurnimator> tralamazza: oh right, 'export' implies extern
<scientes> tralamazza, you can also just use build-obj with export, and then do your own linking
<tralamazza> it does :)
<tralamazza> unfortunately I am using a makefile instead of build.zig, too much friction
<tralamazza> I build the objs and link them manually
<tralamazza> this is fun
<FireFox317> tralamazza: This is how I did it using only zig including build.zig: https://pastebin.com/YYs6CnvU
<FireFox317> Maybe this can help you a bit, I'm still working on it tho
<tralamazza> aha using PROVIDE
<tralamazza> I see
<tralamazza> didn't think of that
<tralamazza> great thanks
<tralamazza> man this .ARM.exidx pops up even if you dont use c++, very annoying
<FireFox317> Jup, that's why I added the discard thing in the linker script
<FireFox317> Actually I found the information on the linker script etc on a embedded Rust page xd
vexu has quit [Quit: WeeChat 2.5]
avoidr_ has joined #zig
avoidr has quit [Ping timeout: 245 seconds]
ross_k has joined #zig
<ross_k> Hi, I'm getting an error trying to upgrade my MSVC zig project to 0.4.0:
<ross_k> "Zig is unable to provide a libc for the chosen target 'x86_64-unknown-windows-msvc'."
<daurnimator> ross_k: where is the -unknown- coming from?
<ross_k> Not sure, it's not something I've specified myself
<daurnimator> (isn't the target just called x86_64-windows-msvc?)
<ross_k> My build.zig: https://pastebin.com/i5JU53P6
<ross_k> It's based on the tetris example: https://github.com/andrewrk/tetris/blob/master/build.zig
<daurnimator> hrm. does msvc even have a libc to link?
<daurnimator> ross_k: I think remove the linking to libc? also I don't think you need the '.lib. postfix on the other libraries
<ross_k> I thought that too, but removing the .lib means it can't find the files
FireFox317 has quit [Ping timeout: 256 seconds]
<ross_k> Cool, removing the linking to libc seems to get me past that issue
athaudia has quit [Quit: Quit]
ross_k has quit [Quit: Page closed]
<emekankurumeh[m]> the unknown comes from llvm. zig use a different form of target triple that discards the second part (vendor) from the llvm triple. that code probably needs to be updated to use zig triples instead of llvm ones.
<emekankurumeh[m]> FireFox317: whenever I tried discarding .ARM.edix i got a linker error about not being able to discard that section
<reaysawa> hi, is the language's grammar available somewhere in BNF or some other human-readable format like that?
<reaysawa> Grammar anchor in the Documentation page doesn't seem to go anywhere
<daurnimator> reaysawa: its on the docs page
<terinjokes> it goes to the "Grammar" section at the end of the docs
<terinjokes> which has the PEG grammar
<daurnimator> reaysawa: https://ziglang.org/documentation/master/#Grammar works for me
marijnfs__ has joined #zig
<daurnimator> if it doesn't work for you; scroll to the bottom of the page
<reaysawa> right, it wasn't working for whatever reason O_O thanks
<reaysawa> my interest is in building some regex rules for generating tags, I'm too used to them for navigating...
<daurnimator> hrm. speaking of, we should have a good git diff config
halosghost has quit [Quit: WeeChat 2.5]
Ichorio_ has quit [Ping timeout: 248 seconds]
marijnfs__ has quit [Ping timeout: 259 seconds]
wootehfoot has quit [Read error: Connection reset by peer]
marijnfs__ has joined #zig
presiden has quit [Quit: WeeChat 2.3]
bgiannan has quit [Quit: WeeChat 2.4]
very-mediocre has quit [Ping timeout: 256 seconds]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
marijnfs__ has quit [Quit: WeeChat 2.3]
knebulae has joined #zig
porky11 has quit [Quit: Leaving]
ltriant has joined #zig
avoidr_ has quit [Quit: leaving]
reaysawa has quit [Ping timeout: 256 seconds]