From 49578305ef3ad4413e394cba4f3e51dd254f7923 Mon Sep 17 00:00:00 2001 From: "Ian A. Mason" Date: Tue, 8 May 2018 15:11:42 -0700 Subject: [PATCH] Fixed some wierdness uncovered by llvm-3.4 bad behavior. Plus puffed out the apache 14.0 tutorial a bit. --- examples/tutorial.md | 75 ++++++++++++++++++++++++++++++++++++++++--- shared/environment.go | 9 ++++-- shared/sanity.go | 8 +++-- 3 files changed, 84 insertions(+), 8 deletions(-) diff --git a/examples/tutorial.md b/examples/tutorial.md index a238d56..d864258 100644 --- a/examples/tutorial.md +++ b/examples/tutorial.md @@ -13,10 +13,25 @@ On a clean 14.04 machine I will build apache. DISTRIB_ID=Ubuntu DISTRIB_RELEASE=14.04 DISTRIB_CODENAME=trusty -DISTRIB_DESCRIPTION="Ubuntu 14.04.2 LTS" +DISTRIB_DESCRIPTION="Ubuntu 14.04.5 LTS" ``` +## Step 0. + +We want a recent version of `go` so we install `1.10`. Currently this requires some effort. + +``` +>sudo add-apt-repository ppa:gophers/archive +>sudo apt-get update +>sudo apt-get install golang-1.10-go + + +>export PATH=/usr/lib/go-1.10/bin:${PATH} +``` + + + ## Step 1. @@ -25,8 +40,6 @@ Install `gllvm`. ``` >export GOPATH=/vagrant/go ->mkdir -p ${GOPATH} - >go get github.com/SRI-CSL/gllvm/cmd/... >export PATH=${GOPATH}/bin:${PATH} @@ -78,7 +91,61 @@ tightly coupled to the gcc and plugin versions you are using. Extract the bitcode. ``` ->get-bc httpd +>get-bc -m httpd ``` +The `-m` flag tells the get-bc tool to also write a manifest listing all the bitcode modules +that were linked together to create the `httpd.bc` module. + +``` + >more httpd.bc.llvm.manifest + +/home/vagrant/httpd-2.4.33/.modules.o.bc +/home/vagrant/httpd-2.4.33/.buildmark.o.bc +/home/vagrant/httpd-2.4.33/server/.main.o.bc +/home/vagrant/httpd-2.4.33/server/.vhost.o.bc +/home/vagrant/httpd-2.4.33/server/.util.o.bc +/home/vagrant/httpd-2.4.33/server/.mpm_common.o.bc +/home/vagrant/httpd-2.4.33/server/.util_filter.o.bc +/home/vagrant/httpd-2.4.33/server/.util_pcre.o.bc +/home/vagrant/httpd-2.4.33/server/.exports.o.bc +/home/vagrant/httpd-2.4.33/server/.scoreboard.o.bc +/home/vagrant/httpd-2.4.33/server/.error_bucket.o.bc +/home/vagrant/httpd-2.4.33/server/.protocol.o.bc +/home/vagrant/httpd-2.4.33/server/.core.o.bc +/home/vagrant/httpd-2.4.33/server/.request.o.bc +/home/vagrant/httpd-2.4.33/server/.provider.o.bc +/home/vagrant/httpd-2.4.33/server/.eoc_bucket.o.bc +/home/vagrant/httpd-2.4.33/server/.eor_bucket.o.bc +/home/vagrant/httpd-2.4.33/server/.core_filters.o.bc +/home/vagrant/httpd-2.4.33/server/.util_expr_eval.o.bc +/home/vagrant/httpd-2.4.33/server/.config.o.bc +/home/vagrant/httpd-2.4.33/server/.log.o.bc +/home/vagrant/httpd-2.4.33/server/.util_fcgi.o.bc +/home/vagrant/httpd-2.4.33/server/.util_script.o.bc +/home/vagrant/httpd-2.4.33/server/.util_md5.o.bc +/home/vagrant/httpd-2.4.33/server/.util_cfgtree.o.bc +/home/vagrant/httpd-2.4.33/server/.util_time.o.bc +/home/vagrant/httpd-2.4.33/server/.connection.o.bc +/home/vagrant/httpd-2.4.33/server/.listen.o.bc +/home/vagrant/httpd-2.4.33/server/.util_mutex.o.bc +/home/vagrant/httpd-2.4.33/server/.mpm_unix.o.bc +/home/vagrant/httpd-2.4.33/server/.mpm_fdqueue.o.bc +/home/vagrant/httpd-2.4.33/server/.util_cookies.o.bc +/home/vagrant/httpd-2.4.33/server/.util_debug.o.bc +/home/vagrant/httpd-2.4.33/server/.util_xml.o.bc +/home/vagrant/httpd-2.4.33/server/.util_regex.o.bc +/home/vagrant/httpd-2.4.33/server/.util_expr_parse.o.bc +/home/vagrant/httpd-2.4.33/server/.util_expr_scan.o.bc +/home/vagrant/httpd-2.4.33/modules/core/.mod_so.o.bc +/home/vagrant/httpd-2.4.33/modules/http/.http_core.o.bc +/home/vagrant/httpd-2.4.33/modules/http/.http_protocol.o.bc +/home/vagrant/httpd-2.4.33/modules/http/.http_request.o.bc +/home/vagrant/httpd-2.4.33/modules/http/.http_filters.o.bc +/home/vagrant/httpd-2.4.33/modules/http/.chunk_filter.o.bc +/home/vagrant/httpd-2.4.33/modules/http/.byterange_filter.o.bc +/home/vagrant/httpd-2.4.33/modules/http/.http_etag.o.bc +/home/vagrant/httpd-2.4.33/server/mpm/event/.event.o.bc +/home/vagrant/httpd-2.4.33/os/unix/.unixd.o.bc +``` diff --git a/shared/environment.go b/shared/environment.go index 9bf7787..cabbe72 100644 --- a/shared/environment.go +++ b/shared/environment.go @@ -107,9 +107,14 @@ func init() { func printEnvironment() { vars := []string{envpath, envcc, envcxx, envar, envlnk, envcfg, envbc, envlvl, envfile} - LogWrite("\nLiving in this environment:\n\n") + informUser("\nLiving in this environment:\n\n") for _, v := range vars { - LogWrite("%v = %v\n", v, os.Getenv(v)) + val, defined := os.LookupEnv(v) + if defined { + informUser("%v = \"%v\"\n", v, val) + } else { + informUser("%v is NOT defined\n", v) + } } } diff --git a/shared/sanity.go b/shared/sanity.go index ff5ea88..5f5f5df 100644 --- a/shared/sanity.go +++ b/shared/sanity.go @@ -212,6 +212,8 @@ func checkExecutable(cmdExecName string, varg string) (success bool, output stri err = cmd.Run() success = (err == nil) output = out.String() + LogInfo("checkExecutable: %s %s returned %s\n", cmdExecName, varg, output) + LogInfo("checkExecutable: returning (%s %s %s)\n", success, output, err) return } @@ -231,7 +233,8 @@ func checkAuxiliaries() bool { linkerOK, linkerVersion, _ := checkExecutable(linkerName, "-version") - if !linkerOK { + // iam: 5/8/2018 3.4 llvm-link and llvm-ar return exit status 1 for -version. GO FIGURE. + if !linkerOK && !strings.Contains(linkerVersion, "LLVM") { informUser("The bitcode linker %s was not found or not executable.\nBetter not try using get-bc!\n", linkerName) informUser(explainLLVMLINKNAME) } else { @@ -241,7 +244,8 @@ func checkAuxiliaries() bool { archiverName = filepath.Join(LLVMToolChainBinDir, archiverName) archiverOK, archiverVersion, _ := checkExecutable(archiverName, "-version") - if !archiverOK { + // iam: 5/8/2018 3.4 llvm-link and llvm-ar return exit status 1 for -version. GO FIGURE. + if !archiverOK && !strings.Contains(linkerVersion, "LLVM") { informUser("The bitcode archiver %s was not found or not executable.\nBetter not try using get-bc!\n", archiverName) informUser(explainLLVMARNAME) } else {