Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blc --configure fails with musl-libc #151

Open
ghost opened this issue Dec 17, 2021 · 14 comments
Open

blc --configure fails with musl-libc #151

ghost opened this issue Dec 17, 2021 · 14 comments
Labels
bug Something isn't working linux

Comments

@ghost
Copy link

ghost commented Dec 17, 2021

I have manually built bl from the source and added blc to the PATH env. But when I run "blc --configure", I ge this error message:

zsh:1: no such file or directory: /ev/çizeylemcil/bl/bin/bl-config
error: Cannot generate config file.

I use a custom musl-libc based linux distro with llvm version 12.0.1(I changed Cmakelists.txt to use llvm 12.0.1). Compilation finnished without any errors, but configuring blc doesn't go through.

@travisdoor
Copy link
Owner

Hmm, I tried fresh clone on Ubuntu and it seems to work, can you please check if the file /ev/çizeylemcil/bl/bin/bl-config exists? If not you can try to copy-paste it from bl/deps/bl-config/linux/bl-config. You can also check if the file is allowed to execute.

@ghost
Copy link
Author

ghost commented Dec 17, 2021

it exists inside the bin directory:

ls -l /ev/çizeylemcil/bl/bin
total 160308
-rwxr-xr-x 1 özcü özcü 47592 Dec 17 13:45 bl-config
-rwxr-xr-x 1 özcü özcü 109382224 Dec 17 13:45 bl-lld
-rwxr-xr-x 1 özcü özcü 54713192 Dec 17 13:45 blc

@travisdoor
Copy link
Owner

OK, the file is distributed as a binary, you can try to execute it manually bl/bin$ ./bl-config -h but it seems like it would not work anyway.

Are you running x86_64?

Btw bl-config produces a configuration file in bl/etc/bl.conf you can try to create it manually, this is how my current one on Ubuntu looks like:

// BL configuration file
// This file is generated by bl-config tool and used by 'blc' compiler during compilation
// process.

VERSION "1.0.0"
// Main API directory containing all modules and source files.
LIB_DIR "/home/travis/bl/lib/bl/api"
// Default linker options used for executable linking.
LINKER_OPT_EXEC "/home/travis/bl/lib/bl/rt/blrt_x86_64_linux.o -dynamic-linker /lib64/ld-linux-x86-64.so.2 -e _start -lc -lm"
// Default linker options used for shared library linking.
LINKER_OPT_SHARED "--shared -lc -lm"
// Additional linker library path.
LINKER_LIB_PATH "/usr/lib:/usr/local/lib:/lib64:/usr/lib/x86_64-linux-gnu"

@ghost
Copy link
Author

ghost commented Dec 17, 2021

I use x86_64 and /etc is symlinked. I tried ./bl-config -h and it gave the same error:

zsh: no such file or directory: ./bl-config

I will manually add the config and see if it works.

@travisdoor
Copy link
Owner

hmm, maybe symlink reading does not work properly...

@ghost
Copy link
Author

ghost commented Dec 17, 2021

this part "/lib64/ld-linux-x86-64.so.2 -e _start -lc -lm" will not work with musl libc. Musl libc has ld-musl-x86_64.so.1.

edit: I created etc folder inside the source dir, and blc asks for input file.

edit2: I have tried to compile a sample code but blc gives me this error:

test.bl:12:13: warning: Unreachable code detected in the function 'fib'.
11 |

12 | return -1;
13 | }

zsh:1: no such file or directory: /ev/çizeylemcil/bl/bin/bl-lld
error(0060): Native link execution failed.
Finished in 0.083 seconds.

edit3: I guess the reason I get "no such file or directory" is because bl-config and bl-lld expects glibc.

@travisdoor
Copy link
Owner

yes, I was kinda expecting this, it seems to be the same issue, bl-lld should be in bin directory (same as bl-config).

@travisdoor
Copy link
Owner

It's possible! Both binaries are compiled with glibc.

@travisdoor
Copy link
Owner

You can try to use your default system linker ld by adding LINKER_EXECUTABLE "/your/path/to/ld" entry into the bl.conf file.

@ghost
Copy link
Author

ghost commented Dec 17, 2021

Now I get all these undefined references:

test.bl:12:13: warning: Unreachable code detected in the function 'fib'.
11 |

12 | return -1;
13 | }

/bin/ld: /ev/çizeylemcil/bl/out.o: in function __os_start': /ev/çizeylemcil/bl/lib/bl/api/os/_linux.bl:125: undefined reference to malloc'
/bin/ld: /ev/çizeylemcil/bl/lib/bl/api/os/_linux.bl:131: undefined reference to strlen' /bin/ld: /ev/çizeylemcil/bl/lib/bl/api/os/_linux.bl:135: undefined reference to free'
/bin/ld: /ev/çizeylemcil/bl/out.o: in function __os_abort_default.344': /ev/çizeylemcil/bl/lib/bl/api/os/_linux.bl:114: undefined reference to raise'
/bin/ld: /ev/çizeylemcil/bl/out.o: in function default_allocator_handler.560': /ev/çizeylemcil/bl/lib/bl/api/std/memory.bl:268: undefined reference to free'
/bin/ld: /ev/çizeylemcil/bl/lib/bl/api/std/memory.bl:265: undefined reference to malloc' /bin/ld: /ev/çizeylemcil/bl/out.o: in function __os_write.523':
/ev/çizeylemcil/bl/lib/bl/api/os/_linux.bl:101: undefined reference to write' /bin/ld: /ev/çizeylemcil/bl/out.o: in function print_any.599':
/ev/çizeylemcil/bl/lib/bl/api/std/print/print.bl:314: undefined reference to memset' /bin/ld: /ev/çizeylemcil/bl/out.o: in function print_f64.630':
/ev/çizeylemcil/bl/lib/bl/api/std/print/print.bl:578: undefined reference to pow' /bin/ld: /ev/çizeylemcil/bl/lib/bl/api/std/print/print.bl:579: undefined reference to ceil'
/bin/ld: /ev/çizeylemcil/bl/out: hidden symbol `llvm.pow.f64' isn't defined
/bin/ld: final link failed: bad value
error(0060): Native link execution failed.
Finished in 0.089 seconds.

@travisdoor
Copy link
Owner

Hmm, this looks like a real blocker, currently, bl is dependent on some stuff from libc, and it's definitely not tested with musl :/ I work on Windows so the support of Linux is limited just to WSL or let's say Ubuntu...

@travisdoor travisdoor added bug Something isn't working linux labels Dec 17, 2021
@travisdoor travisdoor changed the title blc --configure fails blc --configure fails with musl-libc Dec 17, 2021
@ghost
Copy link
Author

ghost commented Dec 17, 2021

Maybe adding support for musl-libc will be a feaute enhancement for future development, I guess. Thanks anyway for your help.

@travisdoor
Copy link
Owner

I'm thinking about it, btw is there any advantage over glibc?

@ghost
Copy link
Author

ghost commented Dec 17, 2021

It produces fairly small binaries when statically linked, supposed to be more stable, less bug prone than glibc. Other than that I don,t know. Here is an introduction if you are interested: https://www.musl-libc.org/intro.html

If you want to try out musl libc in action you could use alpine linux, which is best known to be based on musl-libc. https://alpinelinux.org/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working linux
Projects
None yet
Development

No branches or pull requests

1 participant