<< 13-10-2024 >>

00:08:59tokyovigilantehi, I'm trying to build Nim 2.2 on an Alpine 32 bit host, but even though I've modified time_t to be a 64 bit int (musl c defines this as 64 bit on all platforms) it is still cast to a (32-bit) long, causing compilation of the std lib to fail
00:09:14tokyovigilanteeg a = ((long) (T1_));
00:09:14tokyovigilantetmPtr = localtime((&a));
00:09:34tokyovigilantelocaltime() is expecting a 64 bit type (which T1_ is)
00:10:37tokyovigilanteI've patched posix_other.nim to: Time* {.importc: "time_t", header: "<time.h>".} = distinct int64
00:10:50tokyovigilantewhich is what nimUse64BitCTime does, but this doesn't seem to be enough
00:12:01tokyovigilanteFrom /usr/linux/bits/alltypes.h - typedef _Int64 time_t;
00:21:08FromDiscord<Elegantbeef> What's the full error?
00:21:37tokyovigilantec_code/2_1/@m..@slib@[email protected]:2574:28: error: passing argument 1 of 'localtime' from incompatible pointer type [-Wincompatible-pointer-types]
00:21:54tokyovigilanteusr/include/time.h:60:23: note: expected 'const time_t *' {aka 'const long long int *'} but argument is of type 'long int *'
00:22:20tokyovigilantewhich it is, but I can't understand why the compiler is converting it to a 32-bit int
00:22:39FromDiscord<Elegantbeef> well the issue there is that it's not `const` no?
00:22:46FromDiscord<.tokyovigilante> no, long long vs long
00:23:07FromDiscord<.tokyovigilante> the const may be an issue too, but it's a 32/64 bit issue also
00:23:14FromDiscord<.tokyovigilante> sent a code paste, see https://play.nim-lang.org/#pasty=skfJRIbH
00:23:39FromDiscord<.tokyovigilante> Here's the generated c code, see that T1_ and unix_p0 are correctly 64 bit, but a is recast as a long.
00:24:24FromDiscord<.tokyovigilante> if I change `a = ((long) (T1_));` to `a = (T1_);` and define a as a NI64 as well, it compiles fine
00:24:26FromDiscord<Elegantbeef> Do I ever wish that Nim used stdint and had a `-d:iHateProgrammers` mode 😄
00:25:22FromDiscord<Elegantbeef> Did you change `CTime`?
00:25:48FromDiscord<.tokyovigilante> yup, in posix_other.nim have just forced it to 64 bit
00:26:08FromDiscord<Elegantbeef> Well it still thinks it's 32bit
00:26:14FromDiscord<Elegantbeef> Which is where the cast is from
00:26:16FromDiscord<.tokyovigilante> quite
00:26:18FromDiscord<Elegantbeef> https://github.com/nim-lang/Nim/blob/version-2-2/lib/pure/times.nim#L1330C1-L1330C67
00:26:19FromDiscord<.tokyovigilante> BUT WHY
00:26:22FromDiscord<.tokyovigilante> 😉
00:26:23FromDiscord<Elegantbeef> If you have not do `-f`
00:26:51*lucerne quit (Quit: Ping timeout (120 seconds))
00:27:42FromDiscord<.tokyovigilante> -f for nim -c?
00:27:48FromDiscord<Elegantbeef> Yea
00:28:05*lucerne joined #nim
00:28:14FromDiscord<Elegantbeef> Did you try with base nim and just passing `-d:nimUse64bitCTime`?
00:29:14FromDiscord<.tokyovigilante> no I just deleted that entire conditional from posix_other.nim and forced int64, that seemed to be the only place in the codebase that was defined
00:30:01FromDiscord<.tokyovigilante> Was just a quick hack to try to get the compiler built on alpine
01:02:56*Lord_Nightmare quit (Quit: ZNC - http://znc.in)
01:06:12*Lord_Nightmare joined #nim
01:07:17*Lord_Nightmare quit (Remote host closed the connection)
01:10:34*Lord_Nightmare joined #nim
01:13:11FromDiscord<.tokyovigilante> ah, possibly because the c-sources aren't changed by the compiler during bootstrapping...
03:10:04FromDiscord<majortrips1763> Anyone ever use Katai struct?
03:26:34FromDiscord<Robyn [She/Her]> In reply to @majortrips1763 "Anyone ever use Katai": nope, what is it?
03:29:23FromDiscord<majortrips1763> A DSL for automatically generating libraries, for a number of languages, for a given binary format. Ran across it when looking for an ELF module for Nim.↵- https://kaitai.io/↵- https://github.com/kaitai-io/kaitai_struct_nim_runtime
03:30:50FromDiscord<majortrips1763> The ELF module it automagically generated isn't exactly usable for my needs, but it is interesting non-the-less: https://formats.kaitai.io/elf/nim.html
03:31:24FromDiscord<majortrips1763> (edit) "non-the-less:" => "none-the-less:"
03:32:53FromDiscord<majortrips1763> Just makes me wonder... when a DSL generates code like this .. what license does the output code fall under? 🤔
03:34:26FromDiscord<Elegantbeef> It does say CC0-1.0 so ostensibly that
03:34:59FromDiscord<majortrips1763> Oh, I just saw that.
06:46:04Amun-RaI used kaitai a few times as a documenation on how given format is constructed ;>
07:58:17*ntat joined #nim
08:55:03*coldfeet joined #nim
09:07:20*ntat quit (Quit: Leaving)
09:13:33*ntat joined #nim
10:07:00*mahlon_ joined #nim
10:07:13*mahlon quit (Ping timeout: 248 seconds)
11:11:59FromDiscord<spotlightkid> sent a code paste, see https://play.nim-lang.org/#pasty=DBKEAHpz
13:08:17FromDiscord<kiloneie> What are these propagated exceptions of the nim-lang.org extension, and why do they find 50 errors that lead to imported modules ?
13:12:35FromDiscord<kiloneie> Also i don't recall seeing this b4 and it's bizzare, why can `enum`s have for it's enumerations `valueA = (0, "A string...")` when string is not an ordinal... other containers are not allowed... nor does this break ordinal operations...
13:12:59FromDiscord<kiloneie> (edit) "Also" => "-↵Also"
13:25:45FromDiscord<demotomohiro> In reply to @kiloneie "- Also i don't": https://nim-lang.org/docs/manual.html#types-enumeration-types
13:26:15FromDiscord<demotomohiro> > The compiler supports the built-in stringify operator $ for enumerations. The stringify's result can be controlled by explicitly giving the string values to use:
13:30:19FromDiscord<kiloneie> I did read that, and i don't get it. It's nice, but i don't understand the logic behind it.
13:41:04FromDiscord<demotomohiro> In reply to @kiloneie "I did read that,": When you use `$` for the enum value, specified string literal is used instead of field name: https://play.nim-lang.org/#pasty=xyaGPQRq
13:42:08FromDiscord<sejong> Hello, I just got here, and I'm curious what the most trusted error handling model is in Nim
13:43:28FromDiscord<sejong> (edit) "model is" => "/ async models are" | "Nim" => "Nim.↵↵I know the stdlib has Option types but I'm aware of things like nimfp and zero-functional which seem quite cool, as for async/parallelism I know that the stdlib has async and await but I also do see other third party implementations"
13:45:12FromDiscord<majortrips1763> Okay, yah.. there is a NimMain() that nim adds to this, and we need to surpress the CC from linking to Sctr1.so.. otherwise we have conflict with the `_start()` symbol that automagically ends up in the binary.
13:47:42FromDiscord<majortrips1763> Also .. even though I added pragma's to 2 of these proc's to try and keep Nim from doing _anything_ with them .. it still has a of init work it is trying to do at runtime that would be damaging .. not certain how to surpress that.
13:47:56FromDiscord<majortrips1763> (edit) "Also .. even though I added pragma's to 2 of these proc's to try and keep Nim from doing _anything_ with them .. it still has a ... of" added "lot"
13:48:48FromDiscord<majortrips1763> Well, I mean .. outside of just doing it in C/ASM
13:49:00FromDiscord<odexine> In reply to @sejong "Hello, I just got": Exceptions are still the most supported↵↵Chronos seems to be better tested than the stock library
13:49:47FromDiscord<odexine> In reply to @majortrips1763 "Also .. even though": --noMain:on i think
13:49:52FromDiscord<odexine> Do you have that already
13:51:01FromDiscord<majortrips1763> In reply to @odexine "--noMain:on i think": Yah, I had to add `--passC:-nostartfiles` as well, `--noMain` wasn't good enough
13:53:18FromDiscord<demotomohiro> In reply to @majortrips1763 "Yah, I had to": https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#index-nodefaultlibs↵then, maybe -nodefaultlib?
13:54:23FromDiscord<demotomohiro> I think `-nostartfiles` is a link option and should be used with `--passL`
13:54:44FromDiscord<majortrips1763> In reply to @demotomohiro "https://gcc.gnu.org/onlinedocs/gcc/Link-Options.htm": Yah, this is les about libgcc and friends and more about the linker dragging in Scrt1.o which defines the `_start()` symbol for setting up all the stuff that I just don't need in a kernel ;P
13:55:12FromDiscord<majortrips1763> In reply to @demotomohiro "I think `-nostartfiles` is": Yah, it is .. good catch.
14:04:00FromDiscord<majortrips1763> Oh.. fun read: https://ramanlabs.in/static/blog/raw_memory_management_patterns_in_nim_language.html
14:23:34FromDiscord<majortrips1763> Are there any docs regarding the transforms Nim does on inline ASM? .. some stuff that works in `.S` doesn't seem to work with `asm "..."`
14:26:34FromDiscord<majortrips1763> Though .. I do have an mb2header being properly generated via pure Nim code, so that is kinda nice.
14:28:50FromDiscord<demotomohiro> Only docs I know explains about asm statement in Nim is Nim manual. I dont think there are many people who use inline ASM in Nim.
14:30:50FromDiscord<majortrips1763> Hmm, is there any way to get an enum to be evaluated at compile time?
14:31:16FromDiscord<majortrips1763> `const` is working as expected, but it look like `enum` is runtime only?
14:31:37FromDiscord<majortrips1763> hmmm .. same with `sizeof()` actually .. which is a little curious
14:31:43FromDiscord<demotomohiro> And it seems asm statement in Nim just put the inline ASM in C. So you also needs to know how inline asm in C works: https://gcc.gnu.org/onlinedocs/gcc/Using-Assembly-Language-with-C.html
14:33:12FromDiscord<nikolina.mahin> OK
14:33:17FromDiscord<demotomohiro> `enum` and sizeof should works at compile time.↵But when you use sizeof at compile time, you need to provide type definiton to Nim.
14:33:21FromDiscord<majortrips1763> In reply to @demotomohiro "And it seems asm": Interesting .. yah .. I am familiar with GCC's inline-asm, though I have a few bits of inline asm in Nim that are emitted into C and ASM with some transformations.
14:34:08FromDiscord<nikolina.mahin> kako se ti zoveš sad
14:36:40FromDiscord<nikolina.mahin> kako si ti
14:36:54FromDiscord<majortrips1763> sent a long message, see https://pasty.ee/QpgwFBkp
14:37:41FromDiscord<TFed> what re function to find stuff in string, supports ^ and $ symbols?
14:38:40FromDiscord<TFed> sent a code paste, see https://play.nim-lang.org/#pasty=GpgmDeks
14:39:08FromDiscord<TFed> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/1295032719050408019): what `re` function (to find stuff in string) can support ^ and $ symbols?
14:39:56FromDiscord<TFed> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/1295032719050408019): How search with ^ and $ symbols with `re` functions?
14:40:07FromDiscord<TFed> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/1295032719050408019): How search with ^ and $ symbols in the `re` functions?
14:41:32FromDiscord<majortrips1763> Also, even though I have used `{.exportc.}` to define the exported symbol name on 2 of these procs, only one of the said procs ends up w/ the expected name .. which is a little weird .. I dunno if it is because the other proc has a forward declaration.
14:42:32FromDiscord<majortrips1763> Oh yah .. it was the forward declaration..
14:44:23FromDiscord<demotomohiro> In reply to @majortrips1763 "Yah, I expected both": consts might not exists at runtime if it is not used at runtime.↵`var x SomeObj = SomeObj(...)` in global scope becomes `SomeObj x;` in C code and intialized in the procedure called by NimMain.
14:49:29FromDiscord<majortrips1763> sent a code paste, see https://play.nim-lang.org/#pasty=CaXIiHyz
14:50:51FromDiscord<majortrips1763> sent a code paste, see https://play.nim-lang.org/#pasty=QixtCQtD
14:51:08FromDiscord<majortrips1763> (edit) "https://play.nim-lang.org/#pasty=PuoEYgyi" => "https://play.nim-lang.org/#pasty=tbebidMC"
14:52:10FromDiscord<kiloneie> Omg... Windows defender gives notification, i check details it's "koch.exe", and then that notification disappears and i have no clue how to find it to exclude it... i love this design...
14:54:39FromDiscord<kiloneie> https://media.discordapp.net/attachments/371759389889003532/1295036988147236947/image.png?ex=670d30ae&is=670bdf2e&hm=ff7755fde9235b01788476f5cfc322517232af1f4f5d25654d3e57cec0aa0691&
14:55:10FromDiscord<kiloneie> do any other languages get this obnoxious treatment just because of 1x bad actor ?
14:56:06FromDiscord<demotomohiro> In reply to @majortrips1763 "Yah, that is kinda": it might related to this issue: https://github.com/nim-lang/Nim/issues/12216
14:57:56FromDiscord<majortrips1763> omg .. how to get the addr of a proc so I can cast an address
14:57:56FromDiscord<demotomohiro> In reply to @majortrips1763 "Yah, that is kinda": You should use type conversion like `sizeof(...).uint32` insted of using cast as `cast` might not work at compile time: https://nim-lang.org/docs/manual.html#restrictions-on-compileminustime-execution
14:58:22FromDiscord<tauruuuuuus> In reply to @kiloneie "Omg... Windows defender gives": go used to do to this for me a long time ago, IT contacted me for nim once for this same issue btw lol
14:58:31FromDiscord<tauruuuuuus> I just gave up on windows in the end
15:01:15FromDiscord<demotomohiro> In reply to @majortrips1763 "omg .. how to": https://nim-lang.org/docs/manual.html#types-procedural-type↵Doesn't `cast[uint32](myproc)` work?
15:01:58FromDiscord<majortrips1763> In reply to @demotomohiro "https://nim-lang.org/docs/manual.html#types-procedu": I need to store the addr in a u32 😦
15:02:02FromDiscord<majortrips1763> (edit) "u32" => "uint32"
15:02:43FromDiscord<majortrips1763> > bootstrap.nim(25, 16) Error: VM does not support 'cast' from tyProc to tyUInt32
15:02:49FromDiscord<majortrips1763> Seems it only supports casting that at runtime?
15:05:31FromDiscord<majortrips1763> sent a code paste, see https://play.nim-lang.org/#pasty=NEcmCAoi
15:05:46FromDiscord<demotomohiro> Procedure/function addresses are determined at link time not at Nim compile time. So you can cast proc address only at runtime.
15:06:22FromDiscord<demotomohiro> cannot
15:06:28FromDiscord<takko_the_boss> Nim.
15:08:17FromDiscord<majortrips1763> In reply to @demotomohiro "Procedure/function addresses are determined": Yah, I didn't know `cast` wasn't available at compile time .. not certain how to achieve the equivalent at compile time... feels like it is one of the last 2 little issues in the emitted ASM.
15:12:20FromDiscord<demotomohiro> In reply to @majortrips1763 "I need to store": You might need to use `emit` or `asm` statement or create the issue at Nim repo if it has to be declared as a global variable with initial value in C: https://github.com/nim-lang/Nim/issues/24122
15:13:46FromDiscord<majortrips1763> In reply to @demotomohiro "You might need to": Yah, that option has been on my plate. Was just trying to really get an idea of how far I could go w/ just Nim instead of needing to resort to ASM. Realistically, defining all the MB2 Header Tag's in ASM is a bit of a nightmare. It would have been a lot more pleasant to be able to do that directly in Nim.
15:34:01FromDiscord<majortrips1763> Yah, even this doesn't really fix anything... https://github.com/nim-lang/Nim/pull/12799/files
16:00:23*krux02 joined #nim
16:16:56FromDiscord<majortrips1763> sent a code paste, see https://play.nim-lang.org/#pasty=yYmluKxf
16:23:31FromDiscord<majortrips1763> I am confused .. I don't know of any C compiler that would throw away any struct fields..
16:39:55Amun-RaC compilers are not allowed to optimize out struct fields, but those are not struct fields
16:40:45FromDiscord<majortrips1763> sent a code paste, see https://play.nim-lang.org/#pasty=JoUTeFER
16:41:13FromDiscord<majortrips1763> sent a code paste, see https://play.nim-lang.org/#pasty=qYYISRiK
16:42:13FromDiscord<majortrips1763> I mean .. thjey look like struct fields to me
16:42:20FromDiscord<majortrips1763> (edit) "thjey" => "they"
16:42:33Amun-Rastructs != struct fields
16:42:44Amun-RaC compilers may optimize whole objects out
16:43:05Amun-Rathey can't optimize out just "length" field only
16:43:31Amun-Ratest whether marking those {.exportc.} leaves them is resulting code
16:44:16FromDiscord<majortrips1763> sent a code paste, see https://play.nim-lang.org/#pasty=MMtHfnAm
16:44:44FromDiscord<majortrips1763> Like .. it zeroed everything except `size` on `mb2TagModAlign`, even though it is clearly set in the emitted C
16:45:31FromDiscord<majortrips1763> Looks a little like it is somehow related to the size of the field
16:47:31FromDiscord<spotlightkid> Does anybody have a good template or example for a Git README.md for a Nim (library) project?
16:49:23FromDiscord<majortrips1763> In reply to @Amun-Ra "test whether marking those": Adding `exportc` only changed the ASM label, nothing else.
16:49:30*krux02 quit (Remote host closed the connection)
16:52:38Amun-Rahmm
17:37:56*coldfeet quit (Remote host closed the connection)
19:05:29FromDiscord<majortrips1763> Okay .. soo .. how to setup an `asm goto` label w/ Nim's assembler syntax?↵https://gcc.gnu.org/onlinedocs/gcc/extensions-to-the-c-language-family/how-to-use-inline-assembly-language-in-c-code.html#gotolabels
19:06:55Amun-Ramajortrips1763: https://nim-lang.org/docs/manual.html#pragmas-computedgoto-pragma
19:07:52FromDiscord<majortrips1763> Right, but GCC supports `asm goto` to allow inline ASM to jmp to a C label.
19:08:47*ntat quit (Quit: Leaving)
19:09:44Amun-RaI don't think such thing exists
19:10:53FromDiscord<majortrips1763> hmmm
20:11:34FromDiscord<frusadev> Hello! What the best way of comparing two ref objects? I want to compare their fields not their addresses...
20:13:39FromDiscord<frusadev> Or is there a way for me to get the references of normal objects a certain way?
20:17:50FromDiscord<Elegantbeef> `a[] == b[]`
20:21:20FromDiscord<majortrips1763> sent a code paste, see https://play.nim-lang.org/#pasty=LEdlTIUs
20:26:54FromDiscord<majortrips1763> Oh .. well .. interesting ..
20:57:46*lucasta joined #nim
21:55:07*xet7 quit (Quit: Leaving)
22:02:07*xet7 joined #nim
22:22:33FromDiscord<majortrips1763> So .. is there some magic I need to do to get Nim to produce a static binary?
22:43:42*lucasta quit (Remote host closed the connection)
22:48:28FromDiscord<Elegantbeef> Use musl and statically link all your libraries for linux static libs