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

Wrong environment passed to happy build tool #10633

Open
hsyl20 opened this issue Dec 10, 2024 · 1 comment
Open

Wrong environment passed to happy build tool #10633

hsyl20 opened this issue Dec 10, 2024 · 1 comment

Comments

@hsyl20
Copy link
Collaborator

hsyl20 commented Dec 10, 2024

Describe the bug

This was initially reported in #10072 (comment) but I'm not sure it's the same issue so I don't want to hijack Sebastian's ticket.

  1. I have happy 2.0.2 globally installed (/usr/bin/happy)
  2. For some reason Cabal puts happy 2.1.3 in the build plan and builds it
  3. But then my globally installed happy 2.0.2 is called with the environment variable happy_lib_datadir set to /path/to/happy-lib-2.1.3/data, hence it uses the wrong HappyTemplate.hs and the generated code doesn't compile.

To Reproduce

Steps to reproduce the behavior:

In GHC's source tree:

	# Preparing source files...
	mkdir -p _build/stage0/src/
	cp -rf ./libraries   _build/stage0/src/
	cp -rf ./compiler    _build/stage0/src/libraries/ghc
	cp -rf ./ghc   	     _build/stage0/src/ghc-bin
	cp -rf ./utils       _build/stage0/src/
	
	## Substituting variables
	cp _build/stage0/src/ghc-bin/ghc-bin.cabal{.in,}
	cp _build/stage0/src/libraries/ghc/ghc.cabal{.in,}
	cp _build/stage0/src/libraries/ghc/GHC/CmmToLlvm/Version/Bounds.hs{.in,}
	cp _build/stage0/src/libraries/ghc-boot/ghc-boot.cabal{.in,}
	cp _build/stage0/src/libraries/ghc-boot-th/ghc-boot-th.cabal{.in,}
	cp _build/stage0/src/libraries/ghc-heap/ghc-heap.cabal{.in,}
	cp _build/stage0/src/libraries/ghci/ghci.cabal{.in,}
	cp _build/stage0/src/utils/ghc-pkg/ghc-pkg.cabal{.in,}
	
	sed -i 's/@ProjectVersion@/9.13/' _build/stage0/src/ghc-bin/ghc-bin.cabal
	sed -i 's/@ProjectVersionMunged@/9.13/' _build/stage0/src/ghc-bin/ghc-bin.cabal
	sed -i 's/@ProjectVersion@/9.13/' _build/stage0/src/libraries/ghc/ghc.cabal
	sed -i 's/@ProjectVersionMunged@/9.13/' _build/stage0/src/libraries/ghc/ghc.cabal
	sed -i 's/@ProjectVersion@/9.13/' _build/stage0/src/libraries/ghc-boot/ghc-boot.cabal
	sed -i 's/@ProjectVersionMunged@/9.13/' _build/stage0/src/libraries/ghc-boot/ghc-boot.cabal
	sed -i 's/@ProjectVersion@/9.13/' _build/stage0/src/libraries/ghc-boot-th/ghc-boot-th.cabal
	sed -i 's/@ProjectVersionMunged@/9.13/' _build/stage0/src/libraries/ghc-boot-th/ghc-boot-th.cabal
	sed -i 's/@Suffix@//' _build/stage0/src/libraries/ghc-boot-th/ghc-boot-th.cabal
	sed -i 's/@SourceRoot@/./' _build/stage0/src/libraries/ghc-boot-th/ghc-boot-th.cabal
	sed -i 's/@ProjectVersion@/9.13/' _build/stage0/src/libraries/ghc-heap/ghc-heap.cabal
	sed -i 's/@ProjectVersionMunged@/9.13/' _build/stage0/src/libraries/ghc-heap/ghc-heap.cabal
	sed -i 's/@ProjectVersionForLib@/9.13/' _build/stage0/src/libraries/ghc-heap/ghc-heap.cabal
	sed -i 's/@ProjectVersion@/9.13/' _build/stage0/src/libraries/ghci/ghci.cabal
	sed -i 's/@ProjectVersionMunged@/9.13/' _build/stage0/src/libraries/ghci/ghci.cabal
	sed -i 's/@ProjectVersionForLib@/9.13/' _build/stage0/src/libraries/ghci/ghci.cabal
	sed -i 's/@ProjectVersion@/9.13/'       _build/stage0/src/utils/ghc-pkg/ghc-pkg.cabal
	sed -i 's/@ProjectVersionMunged@/9.13/' _build/stage0/src/utils/ghc-pkg/ghc-pkg.cabal
	sed -i 's/@ProjectVersionForLib@/9.13/' _build/stage0/src/utils/ghc-pkg/ghc-pkg.cabal
	
	sed -i 's/@LlvmMinVersion@/13/' _build/stage0/src/libraries/ghc/GHC/CmmToLlvm/Version/Bounds.hs
	sed -i 's/@LlvmMaxVersion@/20/' _build/stage0/src/libraries/ghc/GHC/CmmToLlvm/Version/Bounds.hs
	
	# Building...
	mkdir -p _build/stage0/cabal/
	mkdir -p _build/stage0/bin/
	
	$(CABAL) build --project-file=cabal.project-stage0 \
	  ghc-bin:ghc ghc-pkg:ghc-pkg genprimopcode:genprimopcode deriveConstants:deriveConstants \
	  -j --builddir=_build/stage0/cabal/
-- cabal.project-stage0
packages:
  ./_build/stage0/src/ghc-bin/
  ./_build/stage0/src/libraries/ghc
  ./_build/stage0/src/libraries/directory/
  ./_build/stage0/src/libraries/file-io/
  ./_build/stage0/src/libraries/filepath/
  ./_build/stage0/src/libraries/ghc-platform/
  ./_build/stage0/src/libraries/ghc-boot/
  ./_build/stage0/src/libraries/ghc-boot-th/
  ./_build/stage0/src/libraries/ghc-heap
  ./_build/stage0/src/libraries/ghci
  ./_build/stage0/src/libraries/os-string/
  ./_build/stage0/src/libraries/process/
  ./_build/stage0/src/libraries/semaphore-compat
  ./_build/stage0/src/libraries/time
  ./_build/stage0/src/libraries/unix/
  ./_build/stage0/src/libraries/Win32/
  ./_build/stage0/src/utils/ghc-pkg
  ./_build/stage0/src/utils/hsc2hs
  ./_build/stage0/src/utils/unlit
  ./_build/stage0/src/utils/genprimopcode/
  ./_build/stage0/src/utils/deriveConstants/

benchmarks: False
tests: False
allow-boot-library-installs: True

program-options
  ghc-options: -fhide-source-paths -j

package *
  library-vanilla: True
  shared: False
  executable-profiling: False
  executable-dynamic: False
  executable-static: False
  ghc-options: -fhide-source-paths -j

package ghc-boot-th
  flags: +bootstrap

-- package genprimopcode
--   flags: -build-tool-depends

allow-newer: ghc-boot-th

Expected behavior

It should build without failing.

System information

  • Operating system: linux
  • Fails with cabal-install 3.14.1.0 and HEAD. Works with cabal-install 3.12.1.0

Additional context

I've bisected and the commit introducing the issue is 8bdda9c (cc @sheaf).

@andreabedini
Copy link
Collaborator

Definitely the exe dependencies have to be added to PATH (at the front). What is globally available should not influence the build.

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

No branches or pull requests

2 participants