Permalink
Browse files

Merge branch 'scion-2nd-attempt'

  • Loading branch information...
2 parents e0cd3e5 + 37d142e commit 6047ffa2bce733af4345a5921cc7e1276a91f778 @nominolo committed Aug 12, 2011
View
115 Makefile
@@ -1,75 +1,40 @@
-.PHONY: default clean install-lib install-deps setup
-
-default: all
-all: build
-
-include config.mk
-
-# If not set in custom config.mk, use the default versions
-HC ?= ghc
-PKG ?= ghc-pkg
-HADDOCK ?= haddock
-
-DIST = dist
-DIST_LIB = $(DIST)/lib
-DIST_SERVER = $(DIST)/server
-SETUP_DIST = setup-dist
-SETUP = $(SETUP_DIST)/Setup
-
-DOTDOTSETUP = cabal
-
-CABAL_INSTALL_OPTS += --ghc --with-compiler=$(HC) --with-hc-pkg=$(PKG)
-CABAL_FLAGS ?=
-# -ftesting
-
-$(DIST)/setup-config: $(SETUP) scion.cabal $(DIST)
- $(SETUP) configure -v --builddir=$(DIST) \
- --with-compiler=$(HC) --with-hc-pkg=$(PKG) \
- --user $(CABAL_FLAGS) > $(DIST)/lib-config-log
-
-$(DIST)/build/libHSscion-0.1.a: $(SETUP) $(DIST)/setup-config $(wildcard lib/**/*.hs lib/**/**/*.hs server/**/*.hs)
- @echo === Building scion ===
- $(SETUP) build --builddir=$(DIST)
-
-$(DIST):
- mkdir $(DIST)
-
-$(SETUP): Setup.hs $(SETUP_DIST)
- $(HC) --make $< -o $@
-
-$(SETUP_DIST):
- mkdir $@
-
-setup: $(SETUP)
-
-build: $(DIST)/build/libHSscion-0.1.a
-
-# TODO: dodgy
-install: $(DIST)/build/libHSscion-0.1.a
- cabal install
-
-# test: build
-# echo main | $(HC) --interactive -package ghc -DDEBUG -isrc -idist/build tests/RunTests.hs
-# # ./dist/build/test_get_imports/test_get_imports $(GHC_PATH)/compiler dist-stage2 +RTS -s -RTS
-
-clean:
- $(SETUP) clean --builddir=$(DIST) || rm -rf $(DIST)
-
-distclean: clean
- rm -rf $(SETUP_DIST)
-
-# doc: configure
-# $(SETUP) haddock --with-haddock=$(HADDOCK)
-
-printvars:
- @echo "UseInplaceGhc = $(UseInplaceGhc)"
- @echo "GHC_PATH = $(GHC_PATH)"
- @echo "HC = $(HC)"
- @echo "PKG = $(PKG)"
- @echo "HADDOCK = $(HADDOCK)"
- @echo "CABAL_INSTALL = $(CABAL_INSTALL)"
- @echo " ..._OPTS = $(CABAL_INSTALL_OPTS)"
- @echo "CABAL_FLAGS = $(CABAL_FLAGS)"
- @echo "---------------------------------------------------------------"
- @echo "DIST_LIB = $(DIST_LIB)"
- @echo "SETUP_DIST = $(SETUP_DIST)"
+default: install
+
+# Create a file config.mk to customise some of these options. This
+# can be useful for example to compile with the HEAD branch of GHC.
+# See config.mk.sample for an example.
+-include config.mk
+
+TOP := $(shell pwd)
+DIST ?= dist
+HC ?= ghc
+RUNHC ?= runghc -f $(HC)
+
+#HC = ghc-6.12.1
+#RUNHC = runghc -f$(HC)
+
+boot:
+ mkdir -p $(DIST)
+
+.PHONY: inplace
+inplace:
+ $(HC) --make -outputdir $(DIST) -isrc -package ghc Scion.Session
+ $(HC) --make -outputdir $(DIST) -isrc -package ghc Scion.Worker.Main
+ $(HC) --make -outputdir $(DIST) -isrc -package ghc src/Worker.hs -o $(DIST)/scion-worker
+# cp src/Worker.hs $(DIST)/Worker.hs
+ echo "#!/bin/sh\n$(DIST)/scion-worker \$${1+\"\$$@\"}" > inplace/scion-worker
+ chmod +x inplace/scion-worker
+ echo "#!/bin/sh\n$(RUNHC) -i\"$(TOP)/src\" -package --ghc-arg=ghc -i\"$(DIST)\" \"$(TOP)/src/Server.hs\"" > inplace/scion-server
+ chmod +x inplace/scion-server
+
+.PHONY: install
+install:
+ time cabal -v install --builddir=$(DIST)/cabal --with-compiler=$(HC)
+
+.PHONY: test
+test:
+ $(RUNHC) test/TestSuite.hs
+
+.PHONY: docs
+docs:
+ cabal -v haddock --builddir=$(DIST)/cabal
View
@@ -0,0 +1,62 @@
+Since version 0.3 Scion uses a multi-process architecture. The Scion
+library starts one or more `scion-worker` processes which do the
+actual work. The Scion library just manages these processes (and
+caches some of their state). This solves the following problems:
+
+ - *Static Flags*. Some of GHC's command line flags can only be set
+ on start-up. This is important mainly for flags that control the
+ kind of compilation (profiled, threaded).
+
+ - *Other write-once state*. GHC only reads the package database once
+ on startup. If new packages have been installed since startup
+ they will not be visible. Changing the database by force while a
+ session is running is likely to cause problems.
+
+ - *Caches*. There are a few caches in GHC that cannot be flushed.
+ These include the name cache, and the package DB cache.
+
+ - *Multiple Compiler Versions*. It is not possible to link to two
+ different versions of GHC from within the same program. If we
+ want to make sure a program compiles with multiple versions of GHC
+ (or multiple combinations of its dependencies) we need to use
+ multiple processes.
+
+The downside of a multi-process architecture is of course the
+additional context switches and communication overhead. To reduce
+this, we:
+
+ - use a binary protocol,
+
+ - cache some information on the library side, and
+
+ - avoid sending too much data between library and worker.
+
+Non-Haskell front-ends use a scion-server that takes the place of the
+library.
+
+The architecture therefore looks as follows:
+
+ +-----------------------+
+ | Non-Haskell frontend |
+ | (Eclipse, Emacs, Vim) |
+ +-----------------------+
+ ^
+ | front-end specific protocol
+ | (e.g., json, s-exprs)
+ v
+ +-----------------+
+ | Scion server / |
+ | Scion library |
+ +-----------------+
+ ^ ^ ^
+ | | | binary protocol
+ v v v
+ +--------------+ +--------------+
+ | Scion worker | ... | Scion worker |
+ +--------------+ +--------------+
+
+If the front-end is written in Haskell, it will take the part of the
+Scion library. The Scion server, in turn, translates between a
+front-end-specific serialisation format to Scion library API calls.
+
+The library-worker protocol is defined in `src/Scion/Types/Commands`.
Oops, something went wrong.

0 comments on commit 6047ffa

Please sign in to comment.