Skip to content

segmentation violation when use C code that do IO #208

@aerphanas

Description

@aerphanas

os: intel x86_64 GNU/Linux Debian 12
myrddin ver: master branch from github

i am trying to do raylib in myrddin, but when i try to run it it crash, i don't know why, i do simple test to check it
here's the code

bld.proj

bin ctest =
	main.myr
	lib cmain
;;

lib cmain =
	cmain.myr
	cmain.glue.c
;;

main.myr

use std
use cmain

const main = { -> void
	cmain.print_hello()
}

cmain.myr

use std

pkg cmain =
	extern const print_hello : (-> void)
;;

cmain.glue.c

/* CFLAGS: -Wall -Wextra */
/* LIBS: c */

#include <stdio.h>

void
cmain$print_hello()
{
	printf("test");
}

when i compile & run it says this

	cc -c -o obj/cmain.glue.o cmain.glue.c -Wall -Wextra
	ar -rcs obj/libcmain.a obj/cmain.o obj/cmain.glue.o
	6m -O obj -I obj main.myr
	ld --gc-sections -o obj/ctest /usr/local/lib/myr/_myrrt.o obj/main.o -Lobj -lcmain -lc -lstd -L/usr/local/lib/myr -lsys -dynamic-linker /lib64/ld-linux-x86-64.so.2
ld: warning: syscall.o: missing .note.GNU-stack section implies executable stack
ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
ctest: exit 1
10887: signal: sys: segmentation violation

but when i change cmain$print_hello() and the rest to just return "int" it works

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions