Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build/doc improvements #48

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
*.app

build/
CMakeUserPresets.json

# CLion stuff
cmake-build-*
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
cmake_minimum_required(VERSION 3.10)

# Include the Conan provider to automatically handle dependencies
set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/conan_provider.cmake")

project(asm-parser)

set(CMAKE_CXX_STANDARD 20)
Expand Down
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,25 @@ Other parameters:

Feeding an objdump via stdin into asm-parser:

`objdump --d a.out -l --insn-width=16 | asm-parser -stdin -binary`
`objdump -d a.out -l --insn-width=16 | asm-parser -stdin -binary`

### Building locally
### Building locally (debug build)

You'll need:
- conan 2 - see `https://github.com/compiler-explorer/asm-parser/blob/main/setup.sh#L1` on how to install and configure
- fmt needs to be build explicitly like so https://github.com/compiler-explorer/asm-parser/blob/main/setup.sh#L12 (don't ask why, no idea)
- `gcc` 12 or similar or later (or hack your settings to support your compiler)
You'll need `gcc` 12 or later (or hack your settings to support your compiler).

Then you can
1. `setup.sh` sets up a venv, installs conan2 in it and uses that to install packages (fmt needs to be explicitly built for some reason):
```
$ ./setup.sh
```

2. Then you can:
```
$ mkdir build
$ cd build
$ cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=<path/to/compiler/if/needed>
$ cmake .. -DCMAKE_BUILD_TYPE=Debug
$ make -j$(nproc)
$ make test
```

(see https://github.com/compiler-explorer/asm-parser/blob/main/build.sh for an example, you might need to configure PATH first before doing so)

The built executable should be found in the path `./build/src/asm-parser` .
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PATH=/opt/compiler-explorer/cmake/bin:/opt/compiler-explorer/ninja:$PWD/.venv/bi

rm -Rf build
mkdir build
cmake -B build -G Ninja -S . -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./conan_provider.cmake -DCMAKE_BUILD_TYPE=Debug
cmake -B build -G Ninja -S . -DCMAKE_BUILD_TYPE=Debug
cmake --build build --config Debug

CURDIR=$PWD
Expand Down
1 change: 1 addition & 0 deletions conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ cmake_layout

[generators]
CMakeDeps
CMakeToolchain
1 change: 1 addition & 0 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ python3 -m venv .venv

.venv/bin/conan profile detect

# Modify the Conan configuration file to retrieve packages with standard C++20
sed -i 's/compiler\.cppstd=.*/compiler.cppstd=20/g' ~/.conan2/profiles/default

.venv/bin/conan install --build=fmt/11.0.0 .
12 changes: 10 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,16 @@ AsmParserConfiguration getConfigurationFromCommandline(const int argc, const cha

int main(int argc, const char **argv)
{
std::locale loc("en_US.UTF-8");
std::locale::global(loc);
try {
std::locale loc("en_US.UTF-8");
std::locale::global(loc);
} catch (const std::runtime_error& e) {
std::cerr << "Failed to set locale: " << e.what() << std::endl;
std::cerr << "Please make sure that the locale is installed on your system:" << std::endl;
std::cerr << "$ sudo apt-get install locales" << std::endl;
std::cerr << "$ locale-gen en_US.UTF-8" << std::endl;
return 1;
}

AsmParser::global_start_timer();

Expand Down