Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit 339800e

Browse files
authored
Rework Docker Image build (#741)
* Try reworking Docker image * Fix some old behavior for building abi libraries I don't think the result is actually usable... * Remove most Python2 references Still left some references to python2 for helper scripts since they aren't tested (afaik) in CI * Fix CI * Remove old CMakeLists.txt and remove support for old TRAILOFBITS_LIBRARIES method of building * Update README
1 parent e42f45f commit 339800e

File tree

9 files changed

+106
-426
lines changed

9 files changed

+106
-426
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
needs: [VersionFile]
2626
strategy:
2727
matrix:
28-
llvm: ["900", "1000", "1100"]
28+
llvm: ["9", "10", "11"]
2929
ubuntu: ["20.04", "18.04"]
3030
steps:
3131
- uses: actions/checkout@v2
@@ -37,6 +37,10 @@ jobs:
3737
run: |
3838
docker run --rm docker.pkg.github.com/lifting-bits/mcsema/mcsema-llvm${{ matrix.llvm }}-ubuntu${{ matrix.ubuntu }}-amd64:latest --version
3939
docker run --rm --entrypoint=mcsema-disass docker.pkg.github.com/lifting-bits/mcsema/mcsema-llvm${{ matrix.llvm }}-ubuntu${{ matrix.ubuntu }}-amd64:latest --help
40+
41+
docker run --rm -v $(pwd)/tests/test_suite_generator/generated/prebuilt_cfg/amd64/linux/cfg:/work docker.pkg.github.com/lifting-bits/mcsema/mcsema-llvm${{ matrix.llvm }}-ubuntu${{ matrix.ubuntu }}-amd64:latest --arch amd64 --os linux --cfg /work/hello_world --output /work/hello_world.bc
42+
docker run --rm -v $(pwd)/tests/test_suite_generator/generated/prebuilt_cfg/x86/linux/cfg:/work docker.pkg.github.com/lifting-bits/mcsema/mcsema-llvm${{ matrix.llvm }}-ubuntu${{ matrix.ubuntu }}-amd64:latest --arch amd64 --os linux --cfg /work/hello_world --output /work/hello_world.bc
43+
4044
- name: Push Image for LLVM ${{ matrix.llvm }} on ${{ matrix.ubuntu }}
4145
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
4246
run: |
@@ -45,23 +49,12 @@ jobs:
4549
docker login -u "${DOCKER_HUB_USER}" -p "${DOCKER_HUB_TOKEN}"
4650
docker tag docker.pkg.github.com/lifting-bits/mcsema/mcsema-llvm${{ matrix.llvm }}-ubuntu${{ matrix.ubuntu }}-amd64:latest trailofbits/mcsema:llvm${{ matrix.llvm }}-ubuntu${{ matrix.ubuntu }}-amd64
4751
docker push trailofbits/mcsema:llvm${{ matrix.llvm }}-ubuntu${{ matrix.ubuntu }}-amd64
52+
4853
env:
4954
GH_USER: ${{ github.actor }}
5055
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5156
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
5257
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
53-
- name: Compress Artifacts LLVM ${{ matrix.llvm }} on ${{ matrix.ubuntu }}
54-
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
55-
run: |
56-
mkdir -p artifacts
57-
cp -v scripts/emit-artifact.sh ./artifacts/
58-
docker run -v "$(pwd)/artifacts:/out" --rm --entrypoint /bin/bash docker.pkg.github.com/lifting-bits/mcsema/mcsema-llvm${{ matrix.llvm }}-ubuntu${{ matrix.ubuntu }}-amd64:latest -c "/out/emit-artifact.sh /out/mcsema-llvm${{ matrix.llvm }}-ubuntu${{ matrix.ubuntu }}-amd64.tar.xz"
59-
ls -l artifacts/
60-
- uses: actions/upload-artifact@v1
61-
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
62-
with:
63-
name: mcsema-llvm${{ matrix.llvm }}-ubuntu${{ matrix.ubuntu }}-amd64.tar.xz
64-
path: artifacts/mcsema-llvm${{ matrix.llvm }}-ubuntu${{ matrix.ubuntu }}-amd64.tar.xz
6558
CreateRelease:
6659
needs: [Docker_Linux, VersionFile]
6760
runs-on: ubuntu-latest

CMakeLists.txt

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,22 @@
1313
# You should have received a copy of the GNU Affero General Public License
1414
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1515

16-
if (NOT DEFINED ENV{TRAILOFBITS_LIBRARIES})
17-
message(STATUS "Using new vcpkg build system")
18-
include(CMakeLists_vcpkg.txt)
19-
return()
20-
endif()
16+
# Find remill first because its config has useful dependency-finding info that
17+
# needs to be found before the CMake `project` declaration
18+
find_package(remill COMPONENTS VCPKG_DEPS QUIET)
2119

22-
project(mcsema)
23-
cmake_minimum_required(VERSION 3.14)
20+
include(cmake/vcpkg_helper.cmake)
2421

25-
# remill
26-
if("${PLATFORM_NAME}" STREQUAL "windows")
27-
set(REMILL_FINDPACKAGE_HINTS HINTS "${CMAKE_INSTALL_PREFIX}/remill/lib")
28-
endif()
22+
project(mcsema C CXX ASM)
23+
24+
include(GNUInstallDirs)
25+
cmake_minimum_required(VERSION 3.14)
2926

30-
find_package(remill REQUIRED ${REMILL_FINDPACKAGE_HINTS})
3127

3228
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/settings.cmake")
3329
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/utils.cmake")
3430
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/BCCompiler.cmake")
3531
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/ccache.cmake")
36-
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
3732

3833
configureCcache()
3934
FindAndSelectClangCompiler()
@@ -54,17 +49,23 @@ if(NOT DEFINED WIN32)
5449
set(PROJECT_CXXFLAGS
5550
${GLOBAL_CXXFLAGS}
5651
-Wconversion
57-
-pedantic
58-
-Wno-unreachable-code-return
52+
-pedantic
53+
-Wno-unreachable-code-return
5954
)
6055
endif()
6156

6257
#
6358
# libraries
6459
#
6560

61+
find_package(remill CONFIG REQUIRED)
62+
list(APPEND PROJECT_LIBRARIES remill_settings remill)
63+
get_target_property(REMILL_INCLUDE_LOCATION remill_settings INTERFACE_INCLUDE_DIRECTORIES)
64+
6665
# protobuf
67-
find_package(Protobuf REQUIRED)
66+
# Compatibility since we use older protobuf CMake functions
67+
set(protobuf_MODULE_COMPATIBLE ON CACHE BOOL "" FORCE)
68+
find_package(Protobuf CONFIG REQUIRED)
6869
list(APPEND PROJECT_LIBRARIES ${Protobuf_LIBRARIES})
6970
list(APPEND PROJECT_INCLUDEDIRECTORIES ${Protobuf_INCLUDE_DIR})
7071
list(APPEND PROJECT_DEFINITIONS "GOOGLE_PROTOBUF_NO_RTTI")
@@ -140,32 +141,15 @@ add_custom_command(
140141
list(APPEND PROJECT_INCLUDEDIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR})
141142

142143
add_dependencies(${MCSEMA_LIFT}
143-
semantics
144144
protobuf_python_module_ida)
145145

146146
#
147147
# libraries
148148
#
149149

150-
# remill
151-
if(NOT TARGET remill)
152-
if("${PLATFORM_NAME}" STREQUAL "windows")
153-
set(REMILL_FINDPACKAGE_HINTS HINTS "${CMAKE_INSTALL_PREFIX}/remill/lib")
154-
endif()
155-
156-
find_package(remill REQUIRED ${REMILL_FINDPACKAGE_HINTS})
157-
endif()
158-
159-
list(APPEND PROJECT_LIBRARIES remill)
160-
161150
# anvill
162-
if(NOT TARGET anvill-${REMILL_LLVM_VERSION})
163-
find_package(anvill REQUIRED)
164-
if(NOT anvill_FOUND)
165-
message(FATAL_ERROR "McSema depends upon Anvill being installed")
166-
endif()
167-
endif()
168-
list(APPEND PROJECT_LIBRARIES anvill-${REMILL_LLVM_VERSION})
151+
find_package(anvill CONFIG REQUIRED)
152+
list(APPEND PROJECT_LIBRARIES anvill)
169153

170154
# mcsema-disass
171155

@@ -191,7 +175,7 @@ set(MCSEMA_PYTHON_SOURCES
191175
if(MCSEMA_INSTALL_PYTHON3_LIBS)
192176
add_custom_target(build_mcsema_disass_python3
193177
DEPENDS ${MCSEMA_PYTHON_SOURCES})
194-
178+
195179
add_custom_command(
196180
TARGET build_mcsema_disass_python3 POST_BUILD
197181
COMMAND which python3 && python3 setup.py build --force

0 commit comments

Comments
 (0)