Skip to content

Commit

Permalink
This project is getting to slow to compile! almost 3 minutes for job
Browse files Browse the repository at this point in the history
  • Loading branch information
Kracken256 committed Jun 24, 2024
1 parent 2e291a2 commit 7b5a609
Show file tree
Hide file tree
Showing 26 changed files with 817 additions and 1,001 deletions.
22 changes: 11 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
cmake_minimum_required(VERSION 3.15)
project(quix-compiler-suite)

if (LIBQUIXCC_SHARED)
add_subdirectory(libquixcc)
else()
if (BUILD_TESTING)
enable_testing()
endif()
option(ONLY_BUILD_LIBQUIXCC "Only build libquixcc" OFF)

if (BUILD_TESTING)
enable_testing()
endif()

add_subdirectory(libquixcc)
add_subdirectory(libquixcc)

if (NOT ONLY_BUILD_LIBQUIXCC)
add_subdirectory(qcc)
add_subdirectory(qld)
add_subdirectory(qpkg)
add_subdirectory(tools)

if (BUILD_TESTING)
add_subdirectory(test)
if (LIBQUIXCC_STATIC)
add_subdirectory(tools)
endif()
endif()
endif()
36 changes: 9 additions & 27 deletions env/Debug.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,43 +1,25 @@
FROM alpine:3.19
FROM ubuntu:22.04

WORKDIR /app
VOLUME /app/

# Install dependencies
RUN apk update
RUN apk add cmake clang make upx git cargo patchelf
RUN apk add -X http://dl-cdn.alpinelinux.org/alpine/v3.18/main llvm14-dev llvm14-static
RUN apt update
RUN apt install -y cmake g++ make llvm-14

# I don't know if all of these are needed, but I use them a lot in other projects
RUN apk add openssl-dev openssl-libs-static zlib-static readline-static \
ncurses-static brotli-static nghttp2-static curl-static zstd-static \
libidn2-static libunistring-static rapidjson-dev yaml-cpp-dev \
curl-dev zlib-dev libdeflate-dev readline-dev libxml2-static \
boost-dev boost-static
RUN apt install -y libssl-dev libboost-all-dev libzstd-dev libclang-common-14-dev rapidjson-dev
RUN apt install -y libyaml-cpp-dev

# Create symlinks for llvm14
RUN cd /usr/include && ln -s llvm14/llvm llvm && ln -s llvm14/llvm-c llvm-c

# Build and install yaml-cpp static library
WORKDIR /tmp
RUN wget https://github.com/jbeder/yaml-cpp/archive/refs/tags/0.8.0.tar.gz -O yaml-cpp-0.8.0.tar.gz
RUN tar -xvf yaml-cpp-0.8.0.tar.gz
WORKDIR /tmp/yaml-cpp-0.8.0
RUN mkdir build
WORKDIR /tmp/yaml-cpp-0.8.0/build
RUN cmake -DYAML_BUILD_SHARED_LIBS=OFF ..
RUN make -j$(nproc) && make install
RUN rm -rf /tmp/yaml-cpp-0.8.0 /tmp/yaml-cpp-0.8.0.tar.gz

# Install tool to merge libraries
RUN cargo install --git https://github.com/tux3/armerge
RUN mv /root/.cargo/bin/armerge /usr/bin
RUN cd /usr/include && ln -s llvm-14/llvm llvm && ln -s llvm-c-14/llvm-c llvm-c
RUN cd /usr/bin && ln -s llvm-config-14 llvm14-config

# Make the build script
RUN echo "#!/bin/sh" > /opt/build.sh
RUN echo "cmake -S /app -B /app/build -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=Off -DLIBQUIXCC_SHARED=Off -DLIBQUIXCC_STATIC=On" >> /opt/build.sh
RUN echo "cmake -S /app -B /app/build -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=Off -DLIBQUIXCC_SHARED=On -DLIBQUIXCC_STATIC=Off" >> /opt/build.sh
RUN echo "cmake --build /app/build -j`nproc`" >> /opt/build.sh
RUN echo "mkdir -p /app/bin" >> /opt/build.sh
RUN echo "cp /app/build/libquixcc/libquixcc.so /app/bin/libquixcc.so" >> /opt/build.sh
RUN echo "cp /app/build/qcc/qcc /app/bin/qcc" >> /opt/build.sh
RUN echo "cp /app/build/qld/qld /app/bin/qld" >> /opt/build.sh
RUN echo "cp /app/build/qpkg/qpkg /app/bin/qpkg" >> /opt/build.sh
Expand Down
42 changes: 16 additions & 26 deletions env/Test.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,41 +1,31 @@
FROM alpine:3.19
FROM ubuntu:22.04

WORKDIR /app
VOLUME /app/

# Install dependencies
RUN apk update
RUN apk add cmake clang make upx git cargo patchelf
RUN apk add -X http://dl-cdn.alpinelinux.org/alpine/v3.18/main llvm14-dev llvm14-static
RUN apt update
RUN apt install -y cmake clang make llvm-14 upx cargo

# I don't know if all of these are needed, but I use them a lot in other projects
RUN apk add openssl-dev openssl-libs-static zlib-static readline-static \
ncurses-static brotli-static nghttp2-static curl-static zstd-static \
libidn2-static libunistring-static rapidjson-dev yaml-cpp-dev \
curl-dev zlib-dev libdeflate-dev readline-dev libxml2-static \
boost-dev boost-static compiler-rt

# Create symlinks for llvm14
RUN cd /usr/include && ln -s llvm14/llvm llvm && ln -s llvm14/llvm-c llvm-c

# Build and install yaml-cpp static library
WORKDIR /tmp
RUN wget https://github.com/jbeder/yaml-cpp/archive/refs/tags/0.8.0.tar.gz -O yaml-cpp-0.8.0.tar.gz
RUN tar -xvf yaml-cpp-0.8.0.tar.gz
WORKDIR /tmp/yaml-cpp-0.8.0
RUN mkdir build
WORKDIR /tmp/yaml-cpp-0.8.0/build
RUN cmake -DYAML_BUILD_SHARED_LIBS=OFF ..
RUN make -j$(nproc) && make install
RUN rm -rf /tmp/yaml-cpp-0.8.0 /tmp/yaml-cpp-0.8.0.tar.gz
RUN apt install -y libssl-dev libboost-all-dev libzstd-dev libclang-common-14-dev rapidjson-dev libyaml-cpp-dev

# Install tool to merge libraries
RUN cargo install --git https://github.com/tux3/armerge
RUN mv /root/.cargo/bin/armerge /usr/bin

# Create symlinks for llvm14
RUN cd /usr/include && ln -s llvm-14/llvm llvm && ln -s llvm-c-14/llvm-c llvm-c
RUN cd /usr/bin && ln -s llvm-config-14 llvm14-config

RUN cd /usr/lib/x86_64-linux-gnu && ln -s /usr/lib/x86_64-linux-gnu/libcrypto.a /usr/lib/libcrypto.a
RUN cd /usr/lib/x86_64-linux-gnu && ln -s /usr/lib/x86_64-linux-gnu/libtinfo.a /usr/lib/libtinfo.a

# Hack to fix term symbol linking
RUN cd /usr/lib/x86_64-linux-gnu && ln -sf /usr/lib/x86_64-linux-gnu/libtinfo.a /usr/lib/libncurses.a

# Make the build script
RUN echo "#!/bin/sh" > /opt/build.sh
RUN echo "cmake -S /app -B /app/build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=On -DLIBQUIXCC_SHARED=Off -DLIBQUIXCC_STATIC=On" >> /opt/build.sh
RUN echo "cmake -S /app -B /app/build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=On -DLIBQUIXCC_SHARED=On -DLIBQUIXCC_STATIC=On" >> /opt/build.sh
RUN echo "cmake --build /app/build -j`nproc`" >> /opt/build.sh
RUN echo "mkdir -p /app/bin" >> /opt/build.sh
RUN echo "cp /app/build/qcc/qcc /app/bin/qcc" >> /opt/build.sh
Expand All @@ -47,4 +37,4 @@ RUN chmod +x /opt/build.sh

WORKDIR /app

CMD ["/opt/build.sh"]
CMD ["/opt/build.sh"]
7 changes: 3 additions & 4 deletions env/libquixcc-shared.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ VOLUME /app/

# Install dependencies
RUN apt update
RUN apt install -y cmake clang make llvm-14

RUN apt install -y libssl-dev libboost-all-dev libzstd-dev libclang-common-14-dev
RUN apt install -y cmake clang make llvm-14 upx cargo
RUN apt install -y libssl-dev libboost-all-dev libzstd-dev libclang-common-14-dev rapidjson-dev libyaml-cpp-dev

# Create symlinks for llvm14
RUN cd /usr/include && ln -s llvm-14/llvm llvm && ln -s llvm-c-14/llvm-c llvm-c
RUN cd /usr/bin && ln -s llvm-config-14 llvm14-config

# Make the build script
RUN echo "#!/bin/sh" > /opt/build.sh
RUN echo "cmake -S /app -B /app/build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=Off -DLIBQUIXCC_SHARED=On -DLIBQUIXCC_STATIC=Off" >> /opt/build.sh
RUN echo "cmake -S /app -B /app/build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=Off -DLIBQUIXCC_SHARED=On -DLIBQUIXCC_STATIC=Off -DONLY_BUILD_LIBQUIXCC=On" >> /opt/build.sh
RUN echo "cmake --build /app/build -j`nproc`" >> /opt/build.sh
RUN echo "mkdir -p /app/bin" >> /opt/build.sh
RUN echo "cp /app/build/libquixcc/libquixcc.so /app/bin/libquixcc.so" >> /opt/build.sh
Expand Down
18 changes: 8 additions & 10 deletions libquixcc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ add_subdirectory(deps/libexecinfo)

set(CMAKE_CXX_STANDARD 20)

# Find C++23 source files
file(GLOB_RECURSE LIBQUIX_CXX_SOURCES "src/*.cc")

# Get LLVM flags from llvm14-config --ldflags
execute_process(COMMAND llvm14-config --ldflags
OUTPUT_VARIABLE LLVM_LD_FLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE)

# Get LLVM flags from llvm14-config --link-static --libfiles
execute_process(COMMAND llvm14-config --link-static --libfiles
OUTPUT_VARIABLE LLVM_LIBS_RAW
OUTPUT_STRIP_TRAILING_WHITESPACE)
Expand All @@ -22,12 +19,9 @@ string(REPLACE "\n" " " LLVM_LIBS "${LLVM_LIBS_RAW}")
string(REPLACE " " ";" LLVM_LIBS "${LLVM_LIBS}")
string(REPLACE "\n" " " LLVM_LIBS_BASH "${LLVM_LIBS_RAW}")

set(BUILD_FLAGS_COMMON -g -Wall -Wextra -pedantic -Werror -Wno-unused-parameter -Wno-error=unused-parameter -Wno-error=unused-variable -Wno-predefined-identifier-outside-function)

SET(BUILD_FLAGS_COMMON -g -Wall -Wextra -pedantic -Werror -Wno-unused-parameter -Wno-error=unused-parameter -Wno-error=unused-variable -Wno-predefined-identifier-outside-function)
SET(PROJECT_RELEASE_FLAGS -O3 -fvisibility=hidden -fvisibility-inlines-hidden -Wno-error=mismatched-new-delete ${BUILD_FLAGS_COMMON} -DNDEBUG)

SET(PROJECT_DEBUG_FLAGS -Wno-error=unused-variable -Wno-error=mismatched-new-delete ${BUILD_FLAGS_COMMON})

SET(PROJECT_DEBUG_FLAGS -Wno-error=unused-variable -Wno-error=mismatched-new-delete -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer ${BUILD_FLAGS_COMMON})
SET(STATIC_PROJECT_RELEASE_FLAGS -O3 -Wno-error=mismatched-new-delete ${BUILD_FLAGS_COMMON})

if (LIBQUIXCC_SHARED)
Expand All @@ -36,10 +30,14 @@ if (LIBQUIXCC_SHARED)
if (CMAKE_BUILD_TYPE STREQUAL "Release")
target_compile_options(quixcc PRIVATE ${PROJECT_RELEASE_FLAGS} -DLLVM_SUUPORT_ALL_TARGETS -flto)
target_link_options(quixcc PRIVATE ${LLVM_LD_FLAGS} -O3 -flto -Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/symexport.map)
target_link_libraries(quixcc PRIVATE tinfo)
add_custom_command(TARGET quixcc POST_BUILD COMMAND ${CMAKE_STRIP} $<TARGET_FILE:quixcc>)
else()
target_compile_options(quixcc PRIVATE ${PROJECT_DEBUG_FLAGS} -DLLVM_SUUPORT_ALL_TARGETS)

target_link_options(quixcc PRIVATE ${LLVM_LD_FLAGS})
target_link_libraries(quixcc PRIVATE -fsanitize=address -fsanitize=undefined)
target_link_libraries(quixcc PRIVATE tinfo)
endif()

if (BUILD_TESTING)
Expand All @@ -51,7 +49,7 @@ if (LIBQUIXCC_SHARED)
target_link_libraries(quixcc PRIVATE ${lib})
message(STATUS "Linking ${lib}")
endforeach()
target_link_libraries(quixcc PRIVATE pthread zstd z tinfo boost_serialization execinfo-static crypto libstdc++.a)
target_link_libraries(quixcc PRIVATE pthread zstd z boost_serialization execinfo-static crypto libstdc++.a)
set_target_properties(quixcc PROPERTIES OUTPUT_NAME quixcc)
endif()

Expand All @@ -70,7 +68,7 @@ if (LIBQUIXCC_STATIC)
target_compile_options(quixcc-static PRIVATE -fprofile-arcs -ftest-coverage -O3 --coverage)
target_link_options(quixcc-static PRIVATE -fprofile-arcs -ftest-coverage -O3 --coverage)
endif()
add_custom_command(TARGET quixcc-static POST_BUILD COMMAND sh -c "armerge --output libquixcc-static.a $<TARGET_FILE:quixcc-static> $<TARGET_FILE:execinfo-static> /usr/lib/libcrypto.a ${LLVM_LIBS_RAW}")
add_custom_command(TARGET quixcc-static POST_BUILD COMMAND sh -c "armerge --output libquixcc-static.a $<TARGET_FILE:quixcc-static> $<TARGET_FILE:execinfo-static> /usr/lib/libncurses.a /usr/lib/libcrypto.a ${LLVM_LIBS_RAW}")

if (BUILD_TESTING)
add_subdirectory(test)
Expand Down
2 changes: 2 additions & 0 deletions libquixcc/internal/IR/Q/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class Type : public Value {
bool verify_impl() const override = 0;

public:
virtual ~Type() = default;

virtual size_t bitcount() const = 0;
size_t size() const;
bool is_ptr() const;
Expand Down
28 changes: 14 additions & 14 deletions libquixcc/internal/IR/delta/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ class I1 : public Type {
boost::uuids::uuid hash_impl() const override;
bool verify_impl() const override;

public:
I1() { ntype = (int)NodeType::I1; }

public:
static const I1 *create();
size_t bitcount() const override { return 1; }
};
Expand All @@ -77,9 +77,9 @@ class I8 : public Type {
boost::uuids::uuid hash_impl() const override;
bool verify_impl() const override;

public:
I8() { ntype = (int)NodeType::I8; }

public:
static const I8 *create();
size_t bitcount() const override { return 8; }
};
Expand All @@ -90,9 +90,9 @@ class I16 : public Type {
boost::uuids::uuid hash_impl() const override;
bool verify_impl() const override;

public:
I16() { ntype = (int)NodeType::I16; }

public:
static const I16 *create();
size_t bitcount() const override { return 16; }
};
Expand All @@ -103,9 +103,9 @@ class I32 : public Type {
boost::uuids::uuid hash_impl() const override;
bool verify_impl() const override;

public:
I32() { ntype = (int)NodeType::I32; }

public:
static const I32 *create();
size_t bitcount() const override { return 32; }
};
Expand All @@ -116,9 +116,9 @@ class I64 : public Type {
boost::uuids::uuid hash_impl() const override;
bool verify_impl() const override;

public:
I64() { ntype = (int)NodeType::I64; }

public:
static const I64 *create();
size_t bitcount() const override { return 64; }
};
Expand All @@ -129,9 +129,9 @@ class I128 : public Type {
boost::uuids::uuid hash_impl() const override;
bool verify_impl() const override;

public:
I128() { ntype = (int)NodeType::I128; }

public:
static const I128 *create();
size_t bitcount() const override { return 128; }
};
Expand All @@ -142,9 +142,9 @@ class U8 : public Type {
boost::uuids::uuid hash_impl() const override;
bool verify_impl() const override;

public:
U8() { ntype = (int)NodeType::U8; }

public:
static const U8 *create();
size_t bitcount() const override { return 8; }
};
Expand All @@ -155,9 +155,9 @@ class U16 : public Type {
boost::uuids::uuid hash_impl() const override;
bool verify_impl() const override;

public:
U16() { ntype = (int)NodeType::U16; }

public:
static const U16 *create();
size_t bitcount() const override { return 16; }
};
Expand All @@ -168,9 +168,9 @@ class U32 : public Type {
boost::uuids::uuid hash_impl() const override;
bool verify_impl() const override;

public:
U32() { ntype = (int)NodeType::U32; }

public:
static const U32 *create();
size_t bitcount() const override { return 32; }
};
Expand All @@ -181,9 +181,9 @@ class U64 : public Type {
boost::uuids::uuid hash_impl() const override;
bool verify_impl() const override;

public:
U64() { ntype = (int)NodeType::U64; }

public:
static const U64 *create();
size_t bitcount() const override { return 64; }
};
Expand All @@ -194,9 +194,9 @@ class U128 : public Type {
boost::uuids::uuid hash_impl() const override;
bool verify_impl() const override;

public:
U128() { ntype = (int)NodeType::U128; }

public:
static const U128 *create();
size_t bitcount() const override { return 128; }
};
Expand All @@ -207,9 +207,9 @@ class F32 : public Type {
boost::uuids::uuid hash_impl() const override;
bool verify_impl() const override;

public:
F32() { ntype = (int)NodeType::F32; }

public:
static const F32 *create();
size_t bitcount() const override { return 32; }
};
Expand All @@ -220,9 +220,9 @@ class F64 : public Type {
boost::uuids::uuid hash_impl() const override;
bool verify_impl() const override;

public:
F64() { ntype = (int)NodeType::F64; }

public:
static const F64 *create();
size_t bitcount() const override { return 64; }
};
Expand All @@ -233,9 +233,9 @@ class Void : public Type {
boost::uuids::uuid hash_impl() const override;
bool verify_impl() const override;

public:
Void() { ntype = (int)NodeType::Void; }

public:
static const Void *create();
size_t bitcount() const override { return 0; }
};
Expand Down
Loading

0 comments on commit 7b5a609

Please sign in to comment.