Skip to content

Commit

Permalink
Merge branch 'main' into fix.128.support
Browse files Browse the repository at this point in the history
  • Loading branch information
dawa79 authored Oct 24, 2024
2 parents 60e6144 + d89e27e commit 11ac9fc
Show file tree
Hide file tree
Showing 213 changed files with 11,819 additions and 8,565 deletions.
49 changes: 43 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,60 @@
name: "Build"
on: [push]
on: [push, pull_request]
jobs:
linux-clang-ASanAndUBSan-build:
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-20.04]
clang: [8]
steps:
- uses: actions/checkout@v3
with:
# Nix Flakes doesn't work on shallow clones
fetch-depth: 0
- uses: cachix/install-nix-action@v18
with:
install_url: https://github.com/numtide/nix-flakes-installer/releases/download/nix-2.4pre20201221_9fab14a/install
extra_nix_config: |
experimental-features = nix-command flakes ca-references
- name: nix build hobbesPackages/clang-${{ matrix.clang }}-ASanAndUBSan/hobbes
run: |
nix build .#hobbesPackages/clang-${{ matrix.clang }}-ASanAndUBSan/hobbes
- name: nix log hobbesPackages/clang-${{ matrix.clang }}-ASanAndUBSan/hobbes
if: ${{ always() }}
run: |
nix log .#hobbesPackages/clang-${{ matrix.clang }}-ASanAndUBSan/hobbes &> ${{ matrix.os }}-clang-${{ matrix.clang }}-ASanAndUBSan-hobbes.log
- name: upload log ${{ matrix.os }}-clang-${{ matrix.clang }}-ASanAndUBSan-hobbes.log
if: ${{ always() }}
uses: actions/upload-artifact@v1
with:
name: output-log-file
path: ${{ matrix.os }}-clang-${{ matrix.clang }}-ASanAndUBSan-hobbes.log
linux-clang-build:
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-20.04]
clang: [6, 8, 10, 11]
clang: [6, 8, 10, 11, 12]
steps:
- uses: actions/checkout@v4
with:
# Nix Flakes doesn't work on shallow clones
fetch-depth: 0
- uses: cachix/install-nix-action@v12
- uses: cachix/install-nix-action@v18
with:
install_url: https://github.com/numtide/nix-flakes-installer/releases/download/nix-2.4pre20201221_9fab14a/install
extra_nix_config: |
experimental-features = nix-command flakes ca-references
- name: nix build hobbesPackages/clang-${{ matrix.clang }}/hobbes
run: |
nix build .#hobbesPackages/clang-${{ matrix.clang }}/hobbes
- name: nix log hobbesPackages/clang-${{ matrix.clang }}/hobbes
if: ${{ always() }}
run: |
nix log .#hobbesPackages/clang-${{ matrix.clang }}/hobbes &> ${{ matrix.os }}-clang-${{ matrix.clang }}-hobbes.log
- name: upload log ${{ matrix.os }}-clang-${{ matrix.clang }}-hobbes.log
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: output-log-file
Expand All @@ -32,22 +65,26 @@ jobs:
matrix:
os: [ubuntu-20.04]
gcc: [10]
llvm: [6, 8, 10, 11]
llvm: [6, 8, 10, 11, 12]
steps:
- uses: actions/checkout@v4
with:
# Nix Flakes doesn't work on shallow clones
fetch-depth: 0
- uses: cachix/install-nix-action@v12
- uses: cachix/install-nix-action@v18
with:
install_url: https://github.com/numtide/nix-flakes-installer/releases/download/nix-2.4pre20201221_9fab14a/install
extra_nix_config: |
experimental-features = nix-command flakes ca-references
- name: nix build hobbesPackages/clang-${{ matrix.clang }}/hobbes
- name: nix build hobbesPackages/gcc-${{ matrix.gcc }}/llvm-${{ matrix.llvm }}/hobbes
run: |
nix build .#hobbesPackages/gcc-${{ matrix.gcc }}/llvm-${{ matrix.llvm }}/hobbes
- name: nix log hobbesPackages/gcc-${{ matrix.gcc }}/llvm-${{ matrix.llvm }}/hobbes
if: ${{ always() }}
run: |
nix log .#hobbesPackages/gcc-${{ matrix.gcc }}/llvm-${{ matrix.llvm }}/hobbes &> ${{ matrix.os }}-gcc-${{ matrix.gcc }}-llvm-${{ matrix.llvm }}-hobbes.log
- name: upload log ${{ matrix.os }}-gcc-${{ matrix.gcc }}-llvm-${{ matrix.llvm }}-hobbes.log
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: output-log-file
Expand Down
76 changes: 76 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# This file is a template, and might need editing before it works on your project.
# To contribute improvements to CI/CD templates, please follow the Development guide at:
# https://docs.gitlab.com/ee/development/cicd/templates.html
# This specific template is located at:
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Getting-Started.gitlab-ci.yml

# This is a sample GitLab CI/CD configuration file that should run without any modifications.
# It demonstrates a basic 3 stage CI/CD pipeline. Instead of real tests or scripts,
# it uses echo commands to simulate the pipeline execution.
#
# A pipeline is composed of independent jobs that run scripts, grouped into stages.
# Stages run in sequential order, but jobs within stages run in parallel.
#
# For more information, see: https://docs.gitlab.com/ee/ci/yaml/README.html#stages
image: nixpkgs/nix-flakes:latest
stages: # List of stages for jobs, and their order of execution
- build
- test
- deploy

build-job-gcc10-llvm11: # This job runs in the build stage, which runs first.
stage: build
script:
- echo "Compiling the code..."
- nix build .#hobbesPackages/gcc-10/llvm-11/hobbes
- echo "Compile complete."
after_script:
- echo "nix log .#hobbesPackages/gcc-10/llvm-11/hobbes..."
- mkdir -pv log-job-gcc10-llvm11
- nix log .#hobbesPackages/gcc-10/llvm-11/hobbes > log-job-gcc10-llvm11/nix.log
- echo "nix log .#hobbesPackages/gcc-10/llvm-11/hobbes complete."
artifacts:
name: "$CI_COMMIT_REF_SLUG"
paths:
- log-job-gcc10-llvm11/
expire_in: 1 week
when: always

build-job-clang11: # This job runs in the build stage, which runs first.
stage: build
script:
- mkdir -pv log-clang-11
- echo "Compiling the code..."
- nix build .#hobbesPackages/clang-11/hobbes; nix log .#hobbesPackages/clang-11/hobbes > log-job-clang-11/nix.log
- echo "Compile complete."
after_script:
- echo "nix log .#hobbesPackages/clang-11/hobbes..."
- mkdir -pv log-job-clang-11
- nix log .#hobbesPackages/clang-11/hobbes > log-job-clang-11/nix.log
- echo "nix log .#hobbesPackages/clang-11/hobbes complete."
artifacts:
name: "$CI_COMMIT_REF_SLUG"
paths:
- log-job-clang-11/
expire_in: 1 week
when: always

unit-test-job-gcc: # This job runs in the test stage.
stage: test # It only starts when the job in the build stage completes successfully.
script:
- echo "Running unit tests... This will take about 60 seconds."
- sleep 60
- echo "Code coverage is 90%"

lint-test-job: # This job also runs in the test stage.
stage: test # It can run at the same time as unit-test-job (in parallel).
script:
- echo "Linting code... This will take about 10 seconds."
- sleep 10
- echo "No lint issues found."

deploy-job: # This job runs in the deploy stage.
stage: deploy # It only runs when *both* jobs in the test stage complete successfully.
script:
- echo "Deploying application..."
- echo "Application successfully deployed."
31 changes: 22 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,21 @@ find_package(Curses REQUIRED)
include_directories(${CURSES_INCLUDE_DIRS})

find_package(LLVM REQUIRED CONFIG)
include_directories(${LLVM_INCLUDE_DIRS})
include_directories(SYSTEM ${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})

if (${LLVM_PACKAGE_VERSION} VERSION_LESS "10.0")
set(CMAKE_CXX_STANDARD 11)
else()
set(CMAKE_CXX_STANDARD 14)
endif()
set(CMAKE_CXX_STANDARD 14)

if (${LLVM_PACKAGE_VERSION} VERSION_LESS "3.6")
set(jit_lib jit)
else()
elseif(${LLVM_PACKAGE_VERSION} VERSION_LESS "11.0")
set(jit_lib mcjit)
else()
set(jit_lib mcjit orcjit)
endif()

find_program(llvm-config llvm-config PATHS ${LLVM_TOOLS_BINARY_DIR})
find_program(llvm-config llvm-config PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH)
find_program(llvm-config llvm-config)
if (${LLVM_PACKAGE_VERSION} VERSION_LESS "4.0")
execute_process(COMMAND ${llvm-config} --libs x86 ipo ${jit_lib}
OUTPUT_VARIABLE llvm_libs
Expand Down Expand Up @@ -82,6 +81,19 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cxx_flags}")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O2")

option(USE_ASAN_UBSAN "Use address,undefined sanitizers" OFF)
if(USE_ASAN_AND_UBSAN)
# _FORTIFY_SOURCE doesn't play well with asan
# https://github.com/google/sanitizers/issues/247
add_definitions(-U_FORTIFY_SOURCE)
add_compile_options("-fno-omit-frame-pointer;-fsanitize=address,undefined;-fno-optimize-sibling-calls;-fno-sanitize-recover=all")
add_link_options("-fsanitize=address,undefined;-fno-optimize-sibling-calls;-fno-sanitize-recover=all")
add_compile_options("$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-fsanitize=local-bounds,float-divide-by-zero,nullability,signed-integer-overflow,shift,integer-divide-by-zero>")
add_link_options("$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-fsanitize=local-bounds,float-divide-by-zero,nullability,signed-integer-overflow,shift,integer-divide-by-zero>")
add_compile_options("$<$<CXX_COMPILER_ID:GNU>:--param=max-vartrack-size=60000000>")
message(STATUS "address and undefined sanitizers enabled")
endif()

add_library(hobbes STATIC ${lib_files})
target_link_libraries(hobbes PUBLIC ${llvm_ldflags} ${llvm_libs} ${ZLIB_LIBRARIES} ${CURSES_LIBRARIES} ${sys_libs})
add_library(hobbes-pic STATIC ${lib_files})
Expand All @@ -94,10 +106,11 @@ add_executable(hog ${hog_files})
target_link_libraries(hog PRIVATE hobbes)

enable_testing()
add_executable(mock-proc test/mocks/proc.C)
add_executable(hobbes-test ${test_files})
target_link_libraries(hobbes-test PRIVATE hobbes)
add_test(hobbes-test hobbes-test)
include(FindPythonInterp)
find_package(PythonInterp 2.7 REQUIRED)
set_property(TARGET hobbes-test PROPERTY COMPILE_FLAGS "-DPYTHON_EXECUTABLE=\"${PYTHON_EXECUTABLE}\" -DSCRIPT_DIR=\"${CMAKE_SOURCE_DIR}/scripts/\"")

install(TARGETS hobbes hobbes-pic DESTINATION "lib")
Expand Down
18 changes: 7 additions & 11 deletions bin/hi/cio.H
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace hi {

// controls display options
typedef unsigned char color;
using color = unsigned char;

DEFINE_STRUCT(ConsoleColors,
(color, promptfg),
Expand Down Expand Up @@ -62,13 +62,13 @@ inline void sendCmd(std::ostream& out, int n0, int n1, int n2, char c) {
}
}

struct setbold { setbold() { } };
struct setbold {};
inline std::ostream& operator<<(std::ostream& lhs, const setbold&) {
sendCmd(lhs, 1, 'm');
return lhs;
}

struct setunderline { setunderline() { } };
struct setunderline {};
inline std::ostream& operator<<(std::ostream& lhs, const setunderline&) {
sendCmd(lhs, 4, 'm');
return lhs;
Expand Down Expand Up @@ -103,18 +103,14 @@ inline std::ostream& operator<<(std::ostream& lhs, const setbgc& c) {
return lhs;
}

struct resetfmt {
resetfmt() { }
};
struct resetfmt {};

inline std::ostream& operator<<(std::ostream& lhs, const resetfmt&) {
sendCmd(lhs, 0, 'm');
return lhs;
}

struct clearscr {
clearscr() { }
};
struct clearscr {};

inline std::ostream& operator<<(std::ostream& lhs, const clearscr&) {
sendCmd(lhs, 2, 'J');
Expand Down Expand Up @@ -151,13 +147,13 @@ inline std::ostream& operator<<(std::ostream& lhs, const movecursor& mc) {
return lhs;
}

struct eraseToEOL { eraseToEOL() { } };
struct eraseToEOL {};
inline std::ostream& operator<<(std::ostream& lhs, const eraseToEOL&) {
sendCmd(lhs, 0, 'K');
return lhs;
}

struct clearline { clearline() { } };
struct clearline {};
inline std::ostream& operator<<(std::ostream& lhs, const clearline&) {
sendCmd(lhs, 2, 'K');
return lhs;
Expand Down
Loading

0 comments on commit 11ac9fc

Please sign in to comment.