Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
0c101b6
[SOL] Use Solana's LLVM fork
jackcmay Feb 13, 2019
df3a7a9
[SOL] Enable LLVM backend
jackcmay Feb 13, 2019
cc1a42d
[SOL] Implement C abi modifier
jackcmay Feb 14, 2019
c45d067
[SOL] Add custom build configuration
jackcmay Feb 14, 2019
91c9aa7
[SOL] Don't build rustdoc to save time
jackcmay Feb 14, 2019
9fd1a09
[SOL] Custom README.md
jackcmay Feb 14, 2019
9e627ed
[SOL] Add build script
jackcmay Feb 20, 2019
b984fbb
[SOL] Preserve lib dir, needed for sysroot building
jackcmay Feb 20, 2019
45e4a3d
[SOL] Allow older gcc, debian does not support a newer one yet
jackcmay Feb 20, 2019
ab987db
[SOL] Reduce size of output binaries
jackcmay Feb 23, 2019
9dd317d
[SOL] Add BPF as a built-in target
jackcmay Feb 27, 2019
f69c2e1
[SOL] Add bin dir later
jackcmay Feb 28, 2019
5eba0c6
[SOL] Update README.md
jackcmay Mar 2, 2019
1228405
[SOL] Script nit
jackcmay Jun 4, 2019
8694769
[SOL] BPF Spec use os=unknown
jackcmay Sep 19, 2019
39b4628
[SOL] Rust libstd requires atomic cas support
jackcmay Sep 25, 2019
a41a012
[SOL] Updates from latest config.example.toml
jackcmay Dec 10, 2019
152fbab
[SOL] Updates from rust 1.39
jackcmay Dec 10, 2019
685bed4
[SOL] Allow all nightly options to help interactions with newer Cargo
jackcmay Apr 28, 2020
f13af96
[SOL] Renames to match the upstream changes
Lichtso Sep 7, 2020
86a0533
[SOL] Disable eh_frame_hdr linker option
dmakarov Feb 10, 2021
2d86226
[SOL] Build llvm tools from llvm-project
jackcmay Feb 16, 2021
77a9535
[SOL] Link llvm tools statically
jackcmay Feb 17, 2021
674ec61
[SOL] Do not disable all builtins for BPF target
dmakarov Feb 17, 2021
ce634da
[SOL] Adjust ABI implementation to pass 128-bit arguments by value
dmakarov Feb 26, 2021
a6a2c20
[SOL] Adjust BPF target spec to upstream changes
dmakarov Feb 28, 2021
3216bfb
[SOL] Adjust for building in tree the bpf target with std library
dmakarov Apr 2, 2021
f26d1b4
[SOL] Update build script to automatically build for correct targets
dmakarov Apr 2, 2021
e505b37
[SOL] Use +solana feature when compiling for BPF target
dmakarov Apr 12, 2021
7c0a83d
[SOL] Document source tree upgrade and bpf-tools release process
dmakarov Apr 12, 2021
be05b47
[SOL] Enable test harness for BPF programs
dmakarov May 7, 2021
94a6c21
[SOL] Fix github actions configuration
dmakarov May 11, 2021
8eab7d6
[SOL] Add linker script and command line options to BPF target spec
dmakarov May 13, 2021
902b08b
[SOL] Fix BPF target spec after upgrade to rust 1.52.1
dmakarov May 17, 2021
0c66a9d
[SOL] Adjust BPF customization after upgrading to rust 1.52.1
dmakarov May 18, 2021
8b1b955
[SOL] Strip full paths from source filenames referred in messages
dmakarov Jun 17, 2021
461752f
[SOL] Adjust BPF customization after upgrading to rust 1.53.0
dmakarov Jul 4, 2021
f8f9aa5
[SOL] Make adjustments to work around CI failures
dmakarov Jul 5, 2021
c8fa8e6
[SOL] Adjust BPF customization after upgrading to rust 1.54.0
dmakarov Aug 5, 2021
ce109e2
[SOL] Add support for windows in build script
joncinque Sep 27, 2021
61f2fdf
[SOL] Adjust BPF customization after upgrading to rust 1.56.0
dmakarov Nov 3, 2021
091687a
[SOL] Enable build on apple silicon
dmakarov Nov 10, 2021
2eb3bae
[SOL] Adjust test harness entrypoint function generation
dmakarov Nov 18, 2021
bbe570b
[SOL] rework test harness codegen a bit
alessandrod Nov 26, 2021
de3ba1f
[SOL] libtest: disable should_panic tests and benchmarks
alessandrod Nov 26, 2021
9a25e76
[SOL] tests: disable failing core tests
alessandrod Nov 26, 2021
0e9057d
[SOL] link using rust-lld
alessandrod Dec 1, 2021
222a5f7
[SOL] CI: run tests for the bpfel-unknown-unknown target
alessandrod Dec 1, 2021
abf5f2a
[SOL] CI: run tests on push and improve run times
alessandrod Dec 6, 2021
29a79ce
[SOL] CI: run push job on solana-* branches instead of master
alessandrod Dec 8, 2021
a4f2af3
[SOL] Install rustup and use more recent cargo and rustc
dmakarov Dec 9, 2021
6c8e612
[SOL] Rename bpf target to sbf
dmakarov Dec 9, 2021
bc5b9bf
[SOL] make all core tests (but atomics) pass
alessandrod Dec 16, 2021
6980c63
[SOL] Fix missing SBF customizations
dmakarov Dec 22, 2021
fb962c5
[SOL] CI: speed up PR runs
alessandrod Jan 3, 2022
1372eb8
[SOL] remove stubs for atomics
alessandrod Jan 3, 2022
72e4efd
[SOL] use codegen-units=1 by default for SBF
alessandrod Feb 4, 2022
ea561cc
[SOL] build: add aarch64-linux target
lithdew Jan 24, 2022
0d3cab9
[SOL] Update run-bpf-tests revision in CI
dmakarov Feb 22, 2022
f730022
[SOL] Adjust BPF customization after upgrading to rust 1.59.0
dmakarov Mar 30, 2022
a1d3a69
[SOL] Update run-bpf-tests revision in CI
dmakarov Apr 2, 2022
db46b10
[SOL] Temporary disable some failing core tests
dmakarov Apr 2, 2022
4b362c5
[SOL] Don't create invalid string slices in stdout/stderr on Solana
brson Feb 18, 2022
14edc13
[SOL] tweak linker script
alessandrod Mar 25, 2022
ee6c973
[SOL] Update run-bpf-tests revision in CI
dmakarov Apr 27, 2022
7b33110
[SOL] Update run-bpf-tests revision in CI
dmakarov May 2, 2022
0dee8b2
[SOL] Prefer command line supplied linker script over embedded one
dmakarov May 2, 2022
bb56817
[SOL] Enable the std backtrace API
Aimeedeer Mar 26, 2022
7531a7c
[SOL] Add os field to SBF target specification
dmakarov May 10, 2022
a05a054
[SOL] sbf: implement static-syscalls target feature
alessandrod May 7, 2022
01250e6
[SOL] sbfv2: place the rodata segment at MM_PROGRAM_START
alessandrod May 14, 2022
9b642bf
[SOL] sbfv2: output _RELATIVE relocations in a separate SHT_RELR section
alessandrod May 14, 2022
5f28955
[SOL] Update run-bpf-tests revision in CI
dmakarov Jul 7, 2022
4f012f6
[SOL] Update run-bpf-tests revision in CI
dmakarov Jul 9, 2022
55e0b6f
[SOL] Adjust BPF customization after upgrading to rust 1.62.0
dmakarov Jul 21, 2022
25564a7
[SOL] Update cargo-run-bpf-test revision for CI
dmakarov Aug 1, 2022
cefe3a4
[SOL] Update run-sbf-tests revision in CI
dmakarov Oct 14, 2022
92cbac4
[SOL] switch to new SBF LLVM backend
dmakarov Oct 24, 2022
e3779d7
[SOL] Adjust SBF customization after upgrading to rust 1.65.0
dmakarov Dec 5, 2022
efb837d
[SOL] Update run-sbf-tests revision in CI
dmakarov Dec 7, 2022
0470bb4
[SOL] Temporarily patch BPF ELF file header with SBF machine code
dmakarov Dec 8, 2022
b54a202
[SOL] Update run-sbf-tests revision in CI
dmakarov Dec 13, 2022
532e28d
[SOL] Add lldb to enabled projects in [llvm] section of config.toml
dmakarov Jan 31, 2023
37a140c
[SOL] Fix Ci error caused by insufficient git history fetched
dmakarov Feb 2, 2023
e61660c
[SOL] Temporarily patch BPF ELF file header only for SBFv2 cpu
dmakarov Feb 20, 2023
8577f44
[SOL] Update run-sbf-tests revision in CI
dmakarov Mar 5, 2023
d9154bd
[SOL] Adjust SBF customization after upgrading to rust 1.68.0
dmakarov Mar 21, 2023
3ce4ae7
[SOL] Set default visibility of symbols in SBF binaries to hidden
dmakarov Aug 16, 2023
5e06016
[SOL] Update run-sbf-tests revision in CI
dmakarov Aug 19, 2023
2791e81
[SOL] Adjust SBF customization after upgrading to rust 1.72.0
dmakarov Sep 26, 2023
334123a
[SOL] Fix CI failures
dmakarov Oct 19, 2023
fad267a
[SOL] Update references to solana-labs redirecting them to anza-xyz
dmakarov Feb 23, 2024
28fa714
[SOL] Set 32 bits for SBF minimum enum size (#90)
LucasSte Feb 26, 2024
05521b0
[SOL] Update SBF call ABI (#91)
LucasSte Mar 13, 2024
520007d
[SOL] CI: build and test sbf target
dmakarov Dec 15, 2021
1be8993
[SOL] Adjust compiler after upgrade to 1.75.0
LucasSte Feb 2, 2024
b604989
[SOL] Adjust compiler after 1.79 upgrade
LucasSte Jul 18, 2024
7652d24
[SOL] Update CI scripts for 1.79
LucasSte Aug 6, 2024
1ef7c4f
[SOL] Update syscalls num (#97)
LucasSte Dec 21, 2024
c4c523f
[SOL] Remove sbfv2 file patch (#98)
LucasSte Jan 23, 2025
8df82a8
[SOL] Bump LLVM commit (#99)
LucasSte Jan 24, 2025
2b767e2
[SOL] Revert "Update syscalls num (#97)" (#100)
LucasSte Jan 24, 2025
8468eae
[SOL] Use SDK custom panic by default (#102)
LucasSte Jan 24, 2025
009746a
[SOL] Bump builtins version (#104)
LucasSte Jan 28, 2025
9cb27dd
[SOL] Update linker commands (#103)
LucasSte Jan 29, 2025
2ecf175
[SOL] Test SBPFv1 and SBPFv2 in CI (#105)
LucasSte Jan 31, 2025
76830ae
[SOL] Implement empty weak custom panic (#108)
LucasSte Feb 5, 2025
0cdd0bc
[SOL] Place abort at address zero in SBPFv3 (#109)
LucasSte Feb 5, 2025
d936908
[SOL] Bump compiler builtins commit (#110)
LucasSte Feb 6, 2025
c8f1ae7
[SOL] Refactor CI and run tests for SBPFv3 (#107)
LucasSte Feb 6, 2025
80947d6
[SOL] Use `.text.abort` section for SBPFv3 (#111)
LucasSte Feb 6, 2025
4c0190a
[SOL] Mark static syscalls as stable (#112)
LucasSte Feb 11, 2025
c93df26
[SOL] Enable store-imm and less than (#113)
LucasSte Feb 12, 2025
74cad7c
[SOL] Bump compiler builtins commit (#114)
LucasSte Feb 13, 2025
8d3f349
[SOL] Split SBPF targets (#117)
LucasSte Feb 14, 2025
d75cae6
[SOL] Set max page size for program header alignment (#118)
LucasSte Mar 6, 2025
8159192
[SOL] Optimize rustlib for size (#119)
LucasSte Mar 6, 2025
c576c87
[SOL] Fixes after Rust 1.84.1 upgrade
LucasSte Mar 10, 2025
7a55511
[SOL] Fix CI for PRs (#125)
LucasSte Apr 10, 2025
0d2f038
[SOL] Change sccache download url for CI (#128)
LucasSte May 7, 2025
b62bd29
[SOL] Allocate less space on stack for drift sort (#127)
LucasSte May 8, 2025
191fcf7
[SOL] Create sbpfv0 target (#129)
LucasSte May 9, 2025
1592062
[SOL] Create sbpfv4 target for ABIv2 (#130)
LucasSte May 12, 2025
6c01488
[SOL] Fix SBPFv4 linker invocation (#132)
LucasSte May 30, 2025
b0454ea
[SOL] Bump versions for release (#134)
LucasSte Jun 12, 2025
60c5d84
[SOL] Refactor SBPFv3 (#135)
LucasSte Jun 27, 2025
7706eb2
[SOL] Simplify linker script for SBPFv3 (#136)
LucasSte Jun 28, 2025
3d8f4f0
[SOL] Revamp CI (#137)
LucasSte Jul 14, 2025
2b9074d
[SOL] Bump version for v1.51 update (#138)
LucasSte Aug 5, 2025
f701778
[SOL] Adjustments after Rust 1.89 upgrade
LucasSte Oct 9, 2025
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
73 changes: 11 additions & 62 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ on:
- try
- try-perf
- automation/bors/try
- master
- solana-**
pull_request:
branches:
- "**"
Expand Down Expand Up @@ -154,8 +156,8 @@ jobs:
# which then uses log commands to actually set them.
EXTRA_VARIABLES: ${{ toJson(matrix.env) }}

- name: ensure the channel matches the target branch
run: src/ci/scripts/verify-channel.sh
# - name: ensure the channel matches the target branch
# run: src/ci/scripts/verify-channel.sh

- name: collect CPU statistics
run: src/ci/scripts/collect-cpu-stats.sh
Expand Down Expand Up @@ -211,14 +213,14 @@ jobs:
- name: disable git crlf conversion
run: src/ci/scripts/disable-git-crlf-conversion.sh

- name: ensure line endings are correct
run: src/ci/scripts/verify-line-endings.sh

- name: ensure backported commits are in upstream branches
run: src/ci/scripts/verify-backported-commits.sh
# - name: ensure line endings are correct
# run: src/ci/scripts/verify-line-endings.sh
#
# - name: ensure backported commits are in upstream branches
# run: src/ci/scripts/verify-backported-commits.sh

- name: ensure the stable version number is correct
run: src/ci/scripts/verify-stable-version-number.sh
# - name: ensure the stable version number is correct
# run: src/ci/scripts/verify-stable-version-number.sh

# Show the environment just before we run the build
# This makes it easier to diagnose problems with the above install scripts.
Expand Down Expand Up @@ -259,59 +261,6 @@ jobs:
echo "disk usage:"
df -h

- name: upload artifacts to github
uses: actions/upload-artifact@v4
with:
# name is set in previous step
name: ${{ env.DOC_ARTIFACT_NAME }}
path: obj/artifacts/doc
if-no-files-found: ignore
retention-days: 5

- name: upload artifacts to S3
run: src/ci/scripts/upload-artifacts.sh
env:
AWS_ACCESS_KEY_ID: ${{ secrets.ARTIFACTS_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.ARTIFACTS_AWS_SECRET_ACCESS_KEY }}
# Adding a condition on DEPLOY=1 or DEPLOY_ALT=1 is not needed as all deploy
# builders *should* have the AWS credentials available. Still, explicitly
# adding the condition is helpful as this way CI will not silently skip
# deploying artifacts from a dist builder if the variables are misconfigured,
# erroring about invalid credentials instead.
if: github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1'

- name: postprocess metrics into the summary
# This step is not critical, and if some I/O problem happens, we don't want
# to cancel the build.
continue-on-error: true
run: |
if [ -f build/metrics.json ]; then
METRICS=build/metrics.json
elif [ -f obj/build/metrics.json ]; then
METRICS=obj/build/metrics.json
else
echo "No metrics.json found"
exit 0
fi

# Get closest bors merge commit
PARENT_COMMIT=`git rev-list --author='bors <[email protected]>' -n1 --first-parent HEAD^1`

./build/citool/debug/citool postprocess-metrics \
--job-name ${CI_JOB_NAME} \
--parent ${PARENT_COMMIT} \
${METRICS} >> ${GITHUB_STEP_SUMMARY}

- name: upload job metrics to DataDog
# This step is not critical, and if some I/O problem happens, we don't want
# to cancel the build.
continue-on-error: true
if: needs.calculate_matrix.outputs.run_type != 'pr'
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DD_GITHUB_JOB_NAME: ${{ matrix.full_name }}
run: ./build/citool/debug/citool upload-build-metrics build/cpu-usage.csv

# This job isused to tell bors the final status of the build, as there is no practical way to detect
# when a workflow is successful listening to webhooks only in our current bors implementation (homu).
outcome:
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
shallow = true
[submodule "src/llvm-project"]
path = src/llvm-project
url = https://github.com/rust-lang/llvm-project.git
url = https://github.com/anza-xyz/llvm-project.git
branch = rustc/20.1-2025-02-13
shallow = true
[submodule "src/doc/embedded-book"]
Expand Down
41 changes: 37 additions & 4 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3144,14 +3144,14 @@ dependencies = [

[[package]]
name = "rustc-build-sysroot"
version = "0.5.8"
version = "0.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16d115ad7e26e0d1337f64ae6598f758194696afc2e9f34c8a6f24582529c3dc"
checksum = "3b881c015c729b43105bbd3702a9bdecee28fafaa21126d1d62e454ec011a4b7"
dependencies = [
"anyhow",
"regex",
"rustc_version",
"tempfile",
"toml 0.8.23",
"walkdir",
]

Expand Down Expand Up @@ -5396,7 +5396,20 @@ dependencies = [
"serde",
"serde_spanned",
"toml_datetime",
"toml_edit",
"toml_edit 0.19.15",
]

[[package]]
name = "toml"
version = "0.8.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362"
dependencies = [
"indexmap",
"serde",
"serde_spanned",
"toml_datetime",
"toml_edit 0.22.27",
]

[[package]]
Expand All @@ -5421,6 +5434,26 @@ dependencies = [
"winnow 0.5.40",
]

[[package]]
name = "toml_edit"
version = "0.22.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a"
dependencies = [
"indexmap",
"serde",
"serde_spanned",
"toml_datetime",
"toml_write",
"winnow 0.7.11",
]

[[package]]
name = "toml_write"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801"

[[package]]
name = "tracing"
version = "0.1.37"
Expand Down
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,50 @@
# Fork of the Rust Programming Language that supports Berkley Packet Filter (BPF) targets

This fork of Rust contains changes that enable rustc to build BPF
modules. It depends on a customized
[fork](https://github.com/anza-xyz/llvm-project) of Rust's LLVM
fork.

Solana SDK does not depend directly on this repo. Instead [platform-tools]
builds and releases binary packages that the Solana SDK pulls in.

[platform-tools]: https://github.com/anza-xyz/platform-tools

BPF modules are built using target triple `bpfel-unknown-unknown`
which represents the little endian version of BPF. There is no
support for big endian at this time.

Upgrading the compiler and standard library source tree
-------------------------------------------------------

The source tree has two external dependencies
1. [compiler-builtins]
2. [llvm-project]

If any of the depencies is changed or this repository is updated to
make a new release of the bpf-tools, tag the dependencies, and this
repository with a new bpf-tools-v1.x tag, so that all components of
the released bpf-tools have the same tag, e.g. bpf-tools-v1.6. Thus,
release of every version of the bpf-tools is fully specified by the
release version.

The [llvm-project] is a submodule of this repository, therefore its
version is explicitly committed in this repository. However,
[compiler-builtins] is pulled in as a cargo package. Therefore, it is
necessary to update the `[patch.crates-io]` subsection of the
top-level `Cargo.toml` file, and specify which tag must be used to
pull the correct version of [compiler-builtins].

After this repository is tagged for a new release, update the
`bpf-tools/build.sh` in [bpf-tools] repository to pull the correct
version of the rust repository and make a new release tag in
[bpf-tools] repository.

[compiler-builtins]: https://github.com/anza-xyz/compiler-builtins
[llvm-project]: https://github.com/anza-xyz/llvm-project

---

<div align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/rust-lang/www.rust-lang.org/master/static/images/rust-social-wide-dark.svg">
Expand Down
27 changes: 27 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SPDX-FileCopyrightText: 2025 Anza Technology Inc. <https://www.anza.xyz>
#
# SPDX-License-Identifier: MIT

#!/usr/bin/env bash

set -ex

if [ "$1" == "--help" ] || [ "$1" == "-h" ]; then
echo "--llvm to rebuild llvm";
exit;
fi

unameOut="$(uname -s)-$(uname -m)"
case "${unameOut}" in
Linux-x86_64*) HOST_TRIPLE=x86_64-unknown-linux-gnu;;
Linux-aarch64*) HOST_TRIPLE=aarch64-unknown-linux-gnu;;
Darwin-x86_64*) HOST_TRIPLE=x86_64-apple-darwin;;
Darwin-arm64*) HOST_TRIPLE=aarch64-apple-darwin;;
MINGW*) HOST_TRIPLE=x86_64-pc-windows-msvc;;
*) HOST_TRIPLE=x86_64-unknown-linux-gnu
esac

if [ "$1" == "--llvm" ]; then
rm -f build/${HOST_TRIPLE}/llvm/llvm-finished-building;
fi
./x.py build --stage 1 --target ${HOST_TRIPLE},sbf-solana-solana,sbpf-solana-solana,sbpfv1-solana-solana,sbpfv2-solana-solana,sbpfv3-solana-solana,sbpfv4-solana-solana
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_gcc/src/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
}
}

pub fn type_void(&self) -> Type<'gcc> {
self.context.new_type::<()>()
}

pub fn type_size_t(&self) -> Type<'gcc> {
self.context.new_type::<usize>()
}
Expand Down Expand Up @@ -180,6 +176,10 @@ impl<'gcc, 'tcx> BaseTypeCodegenMethods for CodegenCx<'gcc, 'tcx> {
bug!("unsupported float width 128")
}

fn type_void(&self) -> Type<'gcc> {
self.context.new_type::<()>()
}

fn type_func(&self, params: &[Type<'gcc>], return_type: Type<'gcc>) -> Type<'gcc> {
self.context.new_function_pointer_type(None, return_type, params, false)
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ impl<'ll> CodegenCx<'ll, '_> {
// and we use it to implement intrinsics like `raw_eq` and `compare_bytes`
if base_name == "memcmp" {
let fn_ty = self
.type_func(&[self.type_ptr(), self.type_ptr(), self.type_isize()], self.type_int());
.type_func(&[self.type_ptr(), self.type_ptr(), self.type_isize()], self.type_i32());
let f = self.declare_cfn("memcmp", llvm::UnnamedAddr::No, fn_ty);

return (fn_ty, f);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
} else {
let n = self.const_usize(layout.size().bytes());
let cmp = self.call_intrinsic("memcmp", &[], &[a, b, n]);
self.icmp(IntPredicate::IntEQ, cmp, self.const_int(self.type_int(), 0))
self.icmp(IntPredicate::IntEQ, cmp, self.const_int(self.type_i32(), 0))
}
}

Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_codegen_llvm/src/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ impl<'ll, CX: Borrow<SCx<'ll>>> BaseTypeCodegenMethods for GenericCx<'ll, CX> {
unsafe { llvm::LLVMFP128TypeInContext(self.llcx()) }
}

fn type_void(&self) -> &'ll Type {
unsafe { llvm::LLVMVoidTypeInContext(self.llcx()) }
}

fn type_func(&self, args: &[&'ll Type], ret: &'ll Type) -> &'ll Type {
unsafe { llvm::LLVMFunctionType(ret, args.as_ptr(), args.len() as c_uint, False) }
}
Expand Down
8 changes: 7 additions & 1 deletion compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1863,17 +1863,23 @@ fn add_pre_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor)
cmd.verbatim_args(&sess.opts.unstable_opts.pre_link_args);
}

/// Add a link script embedded in the target, if applicable.
/// Add a link script embedded in the target, if applicable and not found in the command line.
fn add_link_script(cmd: &mut dyn Linker, sess: &Session, tmpdir: &Path, crate_type: CrateType) {
match (crate_type, &sess.target.link_script) {
(CrateType::Cdylib | CrateType::Executable, Some(script)) => {
if !sess.target.linker_flavor.is_gnu() {
sess.dcx().emit_fatal(errors::LinkScriptUnavailable);
}

if sess.opts.cg.link_args.contains(&String::from("--script"))
|| sess.opts.cg.link_args.contains(&String::from("-T")) {
return;
}

let file_name = ["rustc", &sess.target.llvm_target, "linkfile.ld"].join("-");

let path = tmpdir.join(file_name);

if let Err(error) = fs::write(&path, script.as_ref()) {
sess.dcx().emit_fatal(errors::LinkScriptWriteFailure { path, error });
}
Expand Down
17 changes: 17 additions & 0 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,23 @@ impl<'a> GccLinker<'a> {
self.link_arg(soname);
}
}

if self.sess.target.arch == "bpf" || self.sess.target.arch == "sbf" {
if self.sess.opts.test {
self.link_arg("--entry=main");
} else {
self.link_arg("--entry=entrypoint");
}

let cpu_type = self.sess.opts.cg.target_cpu.as_ref().cloned()
.unwrap_or(self.sess.target.cpu.as_ref().to_string());
if cpu_type == "v3" || cpu_type == "v4" {
self.link_arg("-Bsymbolic");
if self.sess.opts.debuginfo == DebugInfo::None {
self.link_arg("--strip-all");
}
}
}
}
}

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_ssa/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
};

let result = bx.call(start_ty, None, None, start_fn, &args, None, instance);

if cx.sess().target.os.contains("uefi") {
bx.ret(result);
} else {
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_codegen_ssa/src/traits/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ pub trait BaseTypeCodegenMethods: BackendTypes {
fn type_f128(&self) -> Self::Type;

fn type_array(&self, ty: Self::Type, len: u64) -> Self::Type;
fn type_void(&self) -> Self::Type;

fn type_func(&self, args: &[Self::Type], ret: Self::Type) -> Self::Type;
fn type_kind(&self, ty: Self::Type) -> TypeKind;
fn type_ptr(&self) -> Self::Type;
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ declare_features! (
(unstable, riscv_target_feature, "1.45.0", Some(44839)),
(unstable, rtm_target_feature, "1.35.0", Some(44839)),
(unstable, s390x_target_feature, "1.82.0", Some(44839)),
(unstable, sbf_target_feature, "1.54.0", Some(44839)),
(unstable, sparc_target_feature, "1.84.0", Some(132783)),
(unstable, sse4a_target_feature, "1.27.0", Some(44839)),
(unstable, tbm_target_feature, "1.27.0", Some(44839)),
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_llvm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const OPTIONAL_COMPONENTS: &[&str] = &[
"riscv",
"xtensa",
"bpf",
"sbf",
];

const REQUIRED_COMPONENTS: &[&str] =
Expand Down
Loading
Loading