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

Error when trying to install javascript-unknown-ghcjs-xxx using the tui interface #1047

Closed
BinderDavid opened this issue Apr 23, 2024 · 6 comments · Fixed by #1048
Closed

Comments

@BinderDavid
Copy link
Contributor

Problem Description

A while ago I succesfully installed the compiler javascript-unknown-ghcjs-9.6.2 using the instructions in the user guide. That means that I added an additional release channel and installed an emscripten toolchain.

I now updated ghcup using ghcup upgrade and saw that a new compiler javascript-unknown-ghcjs-9.10.0.20240413 is available in the tui interface. Trying to install this new version using the tui interface fails with the following error:

Error: [GHCup-00841] Process "sh" with arguments ["./configure",
                             "--prefix=/home/david/.ghcup/ghc/javascript-unknown-ghcjs-9.10.0.20240413",
                             "--target=javascript-unknown-ghcjs"] failed with exit code 1.

Relevant logs:

.ghcup/logs/ghcup.log

Debug: Identified Platform as: Linux Ubuntu, 22.04
Debug: last access was 286.363387133s ago, cache interval is 300s
Debug: Decoding yaml at: /home/david/.ghcup/cache/ghcup-0.0.8.yaml
Debug: last access was 286.15251809s ago, cache interval is 300s
Debug: Decoding yaml at: /home/david/.ghcup/cache/ghcup-cross-0.0.8.yaml

.ghcup/logs/ghc-configure.log

...
checking whether CC supports -no-pie... yes
checking whether CC supports flags passed by GHC when compiling via C... yes
checking Setting up CFLAGS, LDFLAGS, IGNORE_LINKER_LD_FLAGS and CPPFLAGS... done
checking Setting up CONF_CC_OPTS_STAGE0, CONF_GCC_LINKER_OPTS_STAGE0, CONF_LD_LINKER_OPTS_STAGE0 and CONF_CPP_OPTS_STAGE0... done
checking Setting up CONF_CC_OPTS_STAGE1, CONF_GCC_LINKER_OPTS_STAGE1, CONF_LD_LINKER_OPTS_STAGE1 and CONF_CPP_OPTS_STAGE1... done
checking Setting up CONF_CC_OPTS_STAGE2, CONF_GCC_LINKER_OPTS_STAGE2, CONF_LD_LINKER_OPTS_STAGE2 and CONF_CPP_OPTS_STAGE2... done
checking whether ld.gold supports response files... yes
checking C++ standard library flavour... libstdc++
checking for linkage against 'stdc++'... success
checking for javascript-unknown-ghcjs-otool... no
checking for otool... no
checking for javascript-unknown-ghcjs-install_name_tool... no
checking for install_name_tool... no
checking emsdk version... configure: error: could not determine emsdk version. Perhaps CC is not emcc?

Diagnosis

Installation via the tui doesn't correctly wrap the invocation of ghcup install in an invocation of emconfigure. This is why the installation fails with the message checking emsdk version... configure: error: could not determine emsdk version. Perhaps CC is not emcc?

Workaround

Manually call emconfigure ghcup install ghc --set javascript-unknown-ghcjs-9.10.0.20240413 instead of trying to install via the tui.

Expected Behaviour

Either don't allow the option to install the javascript targets in the tui (which would be acceptable since it is an experimental opt-in feature) or correctly wrap the invocation of the install script with emconfigure.

@hasufell
Copy link
Member

emconfigure ghcup tui works here.

@BinderDavid
Copy link
Contributor Author

Ah, thanks. I didn't know that also works. The other problem I noticed is that the users guide mentions installing ./emsdk install latest, but that installs version 1.58 of emscripten. But javascript-unknown-ghcjs-9.10.0.20240413 can only be installed with emscripten version 1.57.

Maybe both of these issues can be solved by an addition in the specific section in the user guide? I could open a fix for that.
I guess in view of the discussion in #838 it is prudent to not add too much javascript-backend specific code into ghcup and instead wait for a more stable cross-compilation story to emerge on the ghc side.

@hasufell
Copy link
Member

But javascript-unknown-ghcjs-9.10.0.20240413 can only be installed with emscripten version 1.57.

We will need a pre-install message for that here: https://github.com/haskell/ghcup-metadata/blob/94a79c488a01bc6b84e2e724246647ba70e91f5e/ghcup-cross-0.0.8.yaml#L30

      viPreInstall: |
        To install javascript cross backend, you need emscripten 1.57

Or something... can you open a PR?

@BinderDavid
Copy link
Contributor Author

Yes, I can open a PR. I guess javascript-unknown-ghcjs-9.6.2 wasn't similarly tied to a specific emscripten version? I can do some experiments and try to find out.

@BinderDavid
Copy link
Contributor Author

BinderDavid commented Apr 23, 2024

I tried to investigate whether any part of the GHC codebase hardcodes the dependency on a specific version of the emscripten toolchain. That does not seem to be the case. Instead, the logic in this file https://gitlab.haskell.org/ghc/ghc/-/blob/3fff09779d5830549ae455a15907b7bb9fe7859a/distrib/configure.ac.in hardcodes the version of emscripten that was used to build the binary distribution into the configure script which is then checked at installation time. This just happens to be version 1.57 for the binary distribution which is configured in https://github.com/haskell/ghcup-metadata/blob/94a79c488a01bc6b84e2e724246647ba70e91f5e/ghcup-cross-0.0.8.yaml#L30

This behaviour was implemented in the following PR: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10918

See in particular the discussion on the PR here: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10918#note_514310

I think this means that the section in the GHCup user guide about the javascript backend must be updated: For every javascript bindist there is exactly one specific emscripten toolchain that is compatible with it, and the user must install that specific toolchain. I will open a PR about this.

@hasufell
Copy link
Member

I think this means that the section in the GHCup user guide about the javascript backend must be updated

That makes sense. Can you provide a PR?

This behaviour was implemented in the following PR: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10918

I'd argue the configure script error is highly misleading and this warrants a GHC bug report.

checking emsdk version... configure: error: could not determine emsdk version. Perhaps CC is not emcc? doesn't really tell me that I'm running the wrong emscripten version and which one exactly was expected. This is a bad error message. Can you raise a bug report?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants