Skip to content

Commit

Permalink
Add C++ example
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Cain <[email protected]>
  • Loading branch information
androm3da committed Oct 15, 2024
1 parent 72625f2 commit 1372043
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Toolchain for Hexagon is licensed under the BSD 3-clause "New" or "Revised" Lice

## Usage

Refer to [examples](examples/README.md) for sample use cases for this toolchain.

## Building the toolchain

Checkout the required source repos like `llvm-project`, `musl`, etc. Invoke
`get-src-tarballs.sh` with the corresponding `*_SRC_URL` links to the specific
releases to use (see `Dockerfile` for reference / last-known-good versions).
Expand Down
27 changes: 27 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

# Examples of the Opensource Hexagon Toolchain

* Building/running C, C++ programs for linux

```
$ wget https://artifacts.codelinaro.org/artifactory/codelinaro-toolchain-for-hexagon/18.1.0-rc1_02/clang+llvm-18.1.0-rc1-cross-hexagon-unknown-linux-musl.tar.xz
$ sudo tar xf clang+llvm-18.1.0-rc1-cross-hexagon-unknown-linux-musl.tar.xz -C /opt
$ export PATH=/opt/clang+llvm-18.1.0-rc1-cross-hexagon-unknown-linux-musl/x86_64-linux-gnu/bin:$PATH
$ cat <<EOF > example.cpp
#include <iostream>
int main(int argc, const char *argv[]) {
std::cout << "Hello, world!\n";
}
EOF
$ hexagon-unknown-linux-musl-clang++ -static -o ./example_static example.cpp
$ qemu-hexagon ./example_static
Hello, world!
$ hexagon-unknown-linux-musl-clang++ -o ./example example.cpp
$ qemu-hexagon -L /opt/clang+llvm-18.1.0-rc1-cross-hexagon-unknown-linux-musl/x86_64-linux-gnu/target/hexagon-unknown-linux-musl ./example
Hello, world!
```

* See [demo of Rust + zig](contrived/README.md)

0 comments on commit 1372043

Please sign in to comment.