Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Commit

Permalink
ci: fix segfault on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwalker committed Sep 1, 2020
1 parent bbe8c92 commit 05cb632
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
target/
.git/
/target
/.git
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ VERSION ?= `grep 'version' lumen/Cargo.toml | sed -e 's/ //g' -e 's/version=//'
XDG_DATA_HOME ?= $(HOME)/.local/share
LLVM_PREFIX ?= `cd $(XDG_DATA_HOME)/llvm/lumen && pwd`
CWD ?= `pwd`
IMAGE_NAME ?= kronicdeth/lumen-development

help:
@echo "$(NAME):$(VERSION)"
Expand Down Expand Up @@ -122,8 +123,16 @@ rebuild: clean build ## Rebuild all

docker: ## Build Docker image for CI
cd .github/workflows/ && \
docker build --squash --force-rm -t kronicdeth/lumen-development:latest -f Dockerfile .
docker build --squash --force-rm -t $(IMAGE_NAME):latest -f Dockerfile .

linux-shell: ## Run the lumen-dev Docker image
mkdir -p target/docker/target && \
docker run --privileged --rm \
-v $$(pwd):/opt/lumen \
-v $$(pwd)/../llvm-project:/tmp/sources \
-e CARGO_TARGET_DIR=/var/lumen \
-it $(IMAGE_NAME):latest bash -c 'cd /opt/lumen; exec bash'

docker-release: docker
docker push kronicdeth/lumen-development:latest

docker-release: docker
docker push $(IMAGE_NAME):latest
7 changes: 4 additions & 3 deletions bin/build-lumen
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ set -o pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)"
ROOT_DIR="$(cd "$(dirname "$SCRIPT_DIR")" && pwd)"
BIN_DIR="${ROOT_DIR}/bin"
OUTPUT_DIR="${ROOT_DIR}/target/debug"
TARGET_DIR="${CARGO_TARGET_DIR:-${ROOT_DIR}/target}"
OUTPUT_DIR="${TARGET_DIR}/debug"
RUST_TOOLCHAIN="$(rustup show active-toolchain | sed -e 's/ (default)//' | sed -e 's/ (directory override for.*$//')"
RUSTC_PATH="$(rustup which --toolchain "$RUST_TOOLCHAIN" rustc)"
TOOLCHAIN_BIN_PATH="$(cd "$(dirname "$RUSTC_PATH")" && pwd -P)"
Expand Down Expand Up @@ -115,15 +116,15 @@ while [ $# -gt 0 ]; do
;;
-debug | --debug )
extra_rustc_flags="-C opt-level=0"
OUTPUT_DIR="${ROOT_DIR}/target/debug"
OUTPUT_DIR="${TARGET_DIR}/debug"
;;

-only-tblgen | --only-tblgen )
only_tblgen="true"
;;

-release | --release )
OUTPUT_DIR="${ROOT_DIR}/target/release"
OUTPUT_DIR="${TARGET_DIR}/release"
extra_cargo_flags="--release $extra_cargo_flags"
;;

Expand Down
5 changes: 2 additions & 3 deletions compiler/codegen_llvm/lib/lumen/EIR/Builder/MLIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ extern "C" void MLIRRegisterDialects(MLIRContextRef context) {
MLIRContext *ctx = unwrap(context);

// Register the LLVM and EIR dialects with MLIR
ctx->getOrLoadDialect<mlir::StandardOpsDialect>();
ctx->getOrLoadDialect<mlir::LLVM::LLVMDialect>();
ctx->getOrLoadDialect<lumen::eir::eirDialect>();
ctx->loadDialect<mlir::StandardOpsDialect, mlir::LLVM::LLVMDialect, lumen::eir::eirDialect>();
assert(ctx->getLoadedDialects().size() >= 3 && "failed to load dialects!");
}
16 changes: 16 additions & 0 deletions compiler/codegen_llvm/lib/lumen/EIR/Builder/Passes.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
#include "lumen/EIR/Builder/Passes.h"
#include "lumen/EIR/IR/EIRDialect.h"
#include "lumen/EIR/IR/EIROps.h"
#include "lumen/EIR/IR/EIRTypes.h"

#include "mlir/Dialect/StandardOps/IR/Ops.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"

#include "llvm/Support/Casting.h"

using ::mlir::OpBuilder;
using ::mlir::DialectRegistry;
using ::mlir::PassWrapper;
using ::mlir::OperationPass;
using ::mlir::Block;
Expand All @@ -12,6 +19,10 @@ using ::mlir::Location;
using ::mlir::Operation;
using ::mlir::OpOperand;

using ::llvm::isa;
using ::llvm::dyn_cast_or_null;
using ::llvm::cast;

namespace {

using namespace ::lumen::eir;
Expand All @@ -20,6 +31,11 @@ void forAllTraceUses(OpBuilder &, Location, Value, Value, unsigned);

struct InsertTraceConstructorsPass
: public PassWrapper<InsertTraceConstructorsPass, OperationPass<FuncOp>> {
void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<mlir::StandardOpsDialect, mlir::LLVM::LLVMDialect,
lumen::eir::eirDialect>();
}

void runOnOperation() override {
FuncOp op = getOperation();
if (op.isExternal())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef LUMEN_EIR_CONVERSION_CONVERSION_SUPPORT_H
#define LUMEN_EIR_CONVERSION_CONVERSION_SUPPORT_H

#include "llvm/Target/TargetMachine.h"
#include "lumen/EIR/Conversion/TargetInfo.h"
#include "lumen/EIR/IR/EIRAttributes.h"
#include "lumen/EIR/IR/EIROps.h"
#include "lumen/EIR/IR/EIRTypes.h"

#include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h"
#include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
Expand All @@ -21,8 +21,14 @@
#include "mlir/IR/SymbolTable.h"
#include "mlir/Transforms/DialectConversion.h"

#include "llvm/Target/TargetMachine.h"
#include "llvm/Support/Casting.h"

using ::llvm::SmallVectorImpl;
using ::llvm::TargetMachine;
using ::llvm::dyn_cast_or_null;
using ::llvm::cast;
using ::llvm::isa;
using ::mlir::ConversionPatternRewriter;
using ::mlir::LLVMTypeConverter;
using ::mlir::LogicalResult;
Expand Down Expand Up @@ -342,8 +348,6 @@ class RewritePatternContext : public OpConversionContext {
using OpConversionContext::targetInfo;
using OpConversionContext::typeConverter;

inline Location getLoc() const { return op.getLoc(); }

inline const ModuleOp &getModule() const { return parentModule; }

Operation *getOrInsertFunction(StringRef symbol, LLVMType resultTy,
Expand Down Expand Up @@ -421,7 +425,7 @@ class RewritePatternContext : public OpConversionContext {
}
Value encodeImmediate(OpaqueTermType ty, Value val) const {
ModuleOp mod = getModule();
return OpConversionContext::encodeImmediate(mod, getLoc(), ty, val);
return OpConversionContext::encodeImmediate(mod, val.getLoc(), ty, val);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ struct ClosureOpConversion : public EIROpConversion<ClosureOp> {
ClosureOpAdaptor adaptor(operands);
auto ctx = getRewriteContext(op, rewriter);

auto loc = ctx.getLoc();
auto loc = op.getLoc();

assert(op.isAnonymous() && "expected anonymous closures only");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct ConstructMapOpConversion : public EIROpConversion<ConstructMapOp> {
ConstructMapOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
auto ctx = getRewriteContext(op, rewriter);
auto loc = ctx.getLoc();
auto loc = op.getLoc();
ConstructMapOpAdaptor adaptor(operands);

auto termTy = ctx.getUsizeType();
Expand Down Expand Up @@ -59,7 +59,7 @@ struct MapInsertOpConversion : public EIROpConversion<MapInsertOp> {
MapInsertOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
auto ctx = getRewriteContext(op, rewriter);
auto loc = ctx.getLoc();
auto loc = op.getLoc();
MapInsertOpAdaptor adaptor(operands);

auto termTy = ctx.getUsizeType();
Expand Down Expand Up @@ -92,7 +92,7 @@ struct MapUpdateOpConversion : public EIROpConversion<MapUpdateOp> {
MapUpdateOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
auto ctx = getRewriteContext(op, rewriter);
auto loc = ctx.getLoc();
auto loc = op.getLoc();
MapUpdateOpAdaptor adaptor(operands);

auto termTy = ctx.getUsizeType();
Expand Down
10 changes: 7 additions & 3 deletions compiler/codegen_llvm/lib/lumen/EIR/Conversion/TargetInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,23 @@ struct TargetInfoImpl {
TargetInfoImpl(const TargetInfoImpl &other)
: triple(other.triple),
encoding(other.encoding),
pointerWidthIntTy(other.pointerWidthIntTy),
voidTy(other.voidTy),
pointerWidthIntTy(other.pointerWidthIntTy),
i1Ty(other.i1Ty),
i8Ty(other.i8Ty),
i32Ty(other.i32Ty),
i64Ty(other.i64Ty),
bigIntTy(other.bigIntTy),
floatTy(other.floatTy),
doubleTy(other.doubleTy),
binaryTy(other.binaryTy),
binPushResultTy(other.binPushResultTy),
matchResultTy(other.matchResultTy),
recvContextTy(other.recvContextTy),
consTy(other.consTy),
opaqueFnTy(other.opaqueFnTy),
uniqueTy(other.uniqueTy),
defTy(other.defTy),
recvContextTy(other.recvContextTy),
exceptionTy(other.exceptionTy),
erlangErrorTy(other.erlangErrorTy),
nil(other.nil),
Expand All @@ -50,7 +53,8 @@ struct TargetInfoImpl {
boxTag(other.boxTag),
literalTag(other.literalTag),
immediateMask(other.immediateMask),
headerMask(other.headerMask) {}
headerMask(other.headerMask),
immediateBits(other.immediateBits) {}

std::string triple;

Expand Down
18 changes: 11 additions & 7 deletions compiler/codegen_llvm/lib/lumen/EIR/IR/EIROps.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
#include "lumen/EIR/IR/EIROps.h"

#include <iterator>
#include <vector>

#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/SMLoc.h"
#include "lumen/EIR/IR/EIRAttributes.h"
#include "lumen/EIR/IR/EIRTypes.h"

#include "mlir/Dialect/StandardOps/IR/Ops.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h"
Expand All @@ -22,12 +16,22 @@
#include "mlir/Support/LLVM.h"
#include "mlir/Support/LogicalResult.h"

#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/SMLoc.h"

#include <iterator>
#include <vector>

using namespace lumen;
using namespace lumen::eir;

using ::llvm::ArrayRef;
using ::llvm::SmallVector;
using ::llvm::StringRef;
using ::llvm::dyn_cast_or_null;
using ::llvm::cast;
using ::llvm::isa;
using ::mlir::OpOperand;

namespace lumen {
Expand Down
1 change: 1 addition & 0 deletions compiler/mlir/c_src/MLIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ MLIRContextRef MLIRCreateContext(ContextOptions *opts) {
ctx->printOpOnDiagnostic(opts->printOpOnDiagnostic);
ctx->printStackTraceOnDiagnostic(opts->printStackTraceOnDiagnostic);
ctx->enableMultithreading(opts->enableMultithreading);
ctx->allowUnregisteredDialects(false);

return wrap(ctx);
}
Expand Down

0 comments on commit 05cb632

Please sign in to comment.