Compare commits
13 Commits
master
...
bump_to_la
Author | SHA1 | Date |
---|---|---|
Simon Renblad | e894f502a4 | |
Simon Renblad | cd56ef6d48 | |
Simon Renblad | 0a91f883bc | |
Simon Renblad | 3e59dcbc94 | |
Simon Renblad | 4138a65270 | |
Simon Renblad | cb0ec48ef0 | |
Simon Renblad | 14dffaf49c | |
Simon Renblad | bd0c45497e | |
Simon Renblad | 6dc831a8f8 | |
Simon Renblad | aef7dcabae | |
Simon Renblad | 49a84da2ce | |
Simon Renblad | b00f297cd0 | |
Simon Renblad | 526e80401a |
|
@ -1,7 +1,7 @@
|
||||||
[target.armv7-none-eabihf]
|
[target.armv7-none-eabihf]
|
||||||
rustflags = [
|
rustflags = [
|
||||||
"-C", "link-arg=-Tlink.x",
|
"-C", "link-arg=-Tlink.x",
|
||||||
"-C", "target-feature=a9,armv7-a,neon",
|
"-C", "target-feature=+a9,+armv7-a,+neon",
|
||||||
"-C", "target-cpu=cortex-a9",
|
"-C", "target-cpu=cortex-a9",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bit_field"
|
name = "bit_field"
|
||||||
version = "0.10.1"
|
version = "0.10.1"
|
||||||
|
@ -12,6 +14,12 @@ version = "1.3.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitflags"
|
||||||
|
version = "2.6.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "byteorder"
|
name = "byteorder"
|
||||||
version = "1.4.3"
|
version = "1.4.3"
|
||||||
|
@ -32,18 +40,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "compiler_builtins"
|
name = "compiler_builtins"
|
||||||
version = "0.1.39"
|
version = "0.1.109"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3748f82c7d366a0b4950257d19db685d4958d2fa27c6d164a3f069fec42b748b"
|
checksum = "f11973008a8cf741fe6d22f339eba21fd0ca81e2760a769ba8243ed6c21edd7e"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "core_io"
|
|
||||||
version = "0.1.20210325"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "97f8932064288cc79feb4d343a399d353a6f6f001e586ece47fe518a9e8507df"
|
|
||||||
dependencies = [
|
|
||||||
"rustc_version",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "embedded-hal"
|
name = "embedded-hal"
|
||||||
|
@ -70,13 +69,10 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fatfs"
|
name = "fatfs"
|
||||||
version = "0.3.5"
|
version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/rafalh/rust-fatfs?rev=85f06e0#85f06e08edbd3368e1b0562f2fc1b6d178bf7b8a"
|
||||||
checksum = "e18f80a87439240dac45d927fd8f8081b6f1e34c03e97271189fa8a8c2e96c8f"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags 2.6.0",
|
||||||
"byteorder",
|
|
||||||
"core_io",
|
|
||||||
"log",
|
"log",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -111,7 +107,6 @@ dependencies = [
|
||||||
name = "libconfig"
|
name = "libconfig"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"core_io",
|
|
||||||
"fatfs",
|
"fatfs",
|
||||||
"libboard_zynq",
|
"libboard_zynq",
|
||||||
"log",
|
"log",
|
||||||
|
@ -196,28 +191,13 @@ version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bd7a31eed1591dcbc95d92ad7161908e72f4677f8fabf2a32ca49b4237cbf211"
|
checksum = "bd7a31eed1591dcbc95d92ad7161908e72f4677f8fabf2a32ca49b4237cbf211"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc_version"
|
|
||||||
version = "0.1.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084"
|
|
||||||
dependencies = [
|
|
||||||
"semver",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "semver"
|
|
||||||
version = "0.1.20"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smoltcp"
|
name = "smoltcp"
|
||||||
version = "0.7.5"
|
version = "0.7.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3e4a069bef843d170df47e7c0a8bf8d037f217d9f5b325865acc3e466ffe40d3"
|
checksum = "3e4a069bef843d170df47e7c0a8bf8d037f217d9f5b325865acc3e466ffe40d3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags 1.3.2",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"managed",
|
"managed",
|
||||||
]
|
]
|
||||||
|
@ -227,7 +207,7 @@ name = "szl"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"core_io",
|
"fatfs",
|
||||||
"libboard_zynq",
|
"libboard_zynq",
|
||||||
"libconfig",
|
"libconfig",
|
||||||
"libcortex_a9",
|
"libcortex_a9",
|
||||||
|
|
|
@ -9,6 +9,7 @@ members = [
|
||||||
"experiments",
|
"experiments",
|
||||||
"szl",
|
"szl",
|
||||||
]
|
]
|
||||||
|
resolver = "2"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
panic = "abort"
|
panic = "abort"
|
||||||
|
|
|
@ -3,7 +3,7 @@ name = "experiments"
|
||||||
description = "Developing bare-metal Rust on Zynq"
|
description = "Developing bare-metal Rust on Zynq"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
authors = ["M-Labs"]
|
authors = ["M-Labs"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
target_zc706 = ["libboard_zynq/target_zc706", "libsupport_zynq/target_zc706"]
|
target_zc706 = ["libboard_zynq/target_zc706", "libsupport_zynq/target_zc706"]
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![feature(const_in_array_repeat_expressions)]
|
|
||||||
#![feature(naked_functions)]
|
#![feature(naked_functions)]
|
||||||
#![feature(asm)]
|
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
use alloc::collections::BTreeMap;
|
use alloc::collections::BTreeMap;
|
||||||
|
use core::arch::asm;
|
||||||
use libasync::{
|
use libasync::{
|
||||||
delay,
|
delay,
|
||||||
smoltcp::{Sockets, TcpStream},
|
smoltcp::{Sockets, TcpStream},
|
||||||
|
|
|
@ -18,11 +18,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1727540905,
|
"lastModified": 1729181673,
|
||||||
"narHash": "sha256-40J9tW7Y794J7Uw4GwcAKlMxlX2xISBl6IBigo83ih8=",
|
"narHash": "sha256-LDiPhQ3l+fBjRATNtnuDZsBS7hqoBtPkKBkhpoBHv3I=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "fbca5e745367ae7632731639de5c21f29c8744ed",
|
"rev": "4eb33fe664af7b41a4c446f87d20c9a0a6321fa3",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
29
flake.nix
29
flake.nix
|
@ -9,8 +9,8 @@
|
||||||
pkgs = import nixpkgs { system = "x86_64-linux"; overlays = [ (import mozilla-overlay) crosspkgs-overlay ]; };
|
pkgs = import nixpkgs { system = "x86_64-linux"; overlays = [ (import mozilla-overlay) crosspkgs-overlay ]; };
|
||||||
|
|
||||||
rustManifest = pkgs.fetchurl {
|
rustManifest = pkgs.fetchurl {
|
||||||
url = "https://static.rust-lang.org/dist/2021-01-29/channel-rust-nightly.toml";
|
url = "https://static.rust-lang.org/dist/2024-07-19/channel-rust-nightly.toml";
|
||||||
sha256 = "sha256-EZKgw89AH4vxaJpUHmIMzMW/80wAFQlfcxRoBD9nz0c=";
|
sha256 = "sha256-MM2K43Kg+f83XQXT2lI7W/ZdQjLXhMUvA6eGtD+rqDY=";
|
||||||
};
|
};
|
||||||
rustTargets = [];
|
rustTargets = [];
|
||||||
rustChannelOfTargets = _channel: _date: targets:
|
rustChannelOfTargets = _channel: _date: targets:
|
||||||
|
@ -26,14 +26,6 @@
|
||||||
cargo = rust;
|
cargo = rust;
|
||||||
});
|
});
|
||||||
|
|
||||||
# https://doc.rust-lang.org/rustc/linker-plugin-lto.html#toolchain-compatibility
|
|
||||||
llvmPackages_11 = pkgs.recurseIntoAttrs (pkgs.callPackage (import ./llvm/11) ({
|
|
||||||
inherit (pkgs.stdenvAdapters) overrideCC;
|
|
||||||
buildLlvmTools = null;
|
|
||||||
targetLlvmLibraries = null;
|
|
||||||
targetLlvm = null;
|
|
||||||
}));
|
|
||||||
|
|
||||||
crosspkgs-overlay = (self: super: {
|
crosspkgs-overlay = (self: super: {
|
||||||
pkgsCross = super.pkgsCross // {
|
pkgsCross = super.pkgsCross // {
|
||||||
zynq-baremetal = import super.path {
|
zynq-baremetal = import super.path {
|
||||||
|
@ -104,9 +96,7 @@
|
||||||
dontFixup = true;
|
dontFixup = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
cargo-xbuild = pkgs.cargo-xbuild.overrideAttrs(oa: {
|
cargo-xbuild = pkgs.cargo-xbuild;
|
||||||
postPatch = "substituteInPlace src/sysroot.rs --replace 2021 2018";
|
|
||||||
});
|
|
||||||
|
|
||||||
build-crate = name: crate: features: rustPlatform.buildRustPackage rec {
|
build-crate = name: crate: features: rustPlatform.buildRustPackage rec {
|
||||||
name = "${crate}";
|
name = "${crate}";
|
||||||
|
@ -114,9 +104,14 @@
|
||||||
src = builtins.filterSource (path: type:
|
src = builtins.filterSource (path: type:
|
||||||
baseNameOf path != "target"
|
baseNameOf path != "target"
|
||||||
) ./.;
|
) ./.;
|
||||||
cargoLock = { lockFile = ./Cargo.lock; };
|
cargoLock = {
|
||||||
|
lockFile = ./Cargo.lock;
|
||||||
|
outputHashes = {
|
||||||
|
"fatfs-0.4.0" = "sha256-P7IgvhwTPXtNhcyv8cFqwO2UdaEcCGJY7UBG6+yBFSg=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [ cargo-xbuild llvmPackages_11.clang-unwrapped ];
|
nativeBuildInputs = [ cargo-xbuild pkgs.llvmPackages_18.clang-unwrapped ];
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
export XARGO_RUST_SRC="${rust}/lib/rustlib/src/rust/library"
|
export XARGO_RUST_SRC="${rust}/lib/rustlib/src/rust/library"
|
||||||
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
|
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
|
||||||
|
@ -161,7 +156,7 @@
|
||||||
|
|
||||||
hydraJobs = packages.x86_64-linux;
|
hydraJobs = packages.x86_64-linux;
|
||||||
|
|
||||||
inherit rust rustPlatform llvmPackages_11;
|
inherit rust rustPlatform;
|
||||||
|
|
||||||
devShell.x86_64-linux = pkgs.mkShell {
|
devShell.x86_64-linux = pkgs.mkShell {
|
||||||
name = "zynq-rs-dev-shell";
|
name = "zynq-rs-dev-shell";
|
||||||
|
@ -172,7 +167,7 @@
|
||||||
|
|
||||||
pkgs.openocd pkgs.gdb
|
pkgs.openocd pkgs.gdb
|
||||||
pkgs.openssh pkgs.rsync
|
pkgs.openssh pkgs.rsync
|
||||||
llvmPackages_11.clang-unwrapped
|
pkgs.llvmPackages_18.clang-unwrapped
|
||||||
(pkgs.python3.withPackages(ps: [ ps.pyftdi ]))
|
(pkgs.python3.withPackages(ps: [ ps.pyftdi ]))
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,7 +3,7 @@ name = "libasync"
|
||||||
description = "low-level async support"
|
description = "low-level async support"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
authors = ["M-Labs"]
|
authors = ["M-Labs"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
#futures = { version = "0.3", default-features = false }
|
#futures = { version = "0.3", default-features = false }
|
||||||
|
|
|
@ -3,7 +3,7 @@ name = "libboard_zynq"
|
||||||
description = "Drivers for peripherals in the Zynq PS"
|
description = "Drivers for peripherals in the Zynq PS"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
authors = ["M-Labs"]
|
authors = ["M-Labs"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
target_zc706 = []
|
target_zc706 = []
|
||||||
|
|
|
@ -2,14 +2,18 @@
|
||||||
name = "libconfig"
|
name = "libconfig"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["M-Labs"]
|
authors = ["M-Labs"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libboard_zynq = { path = "../libboard_zynq" }
|
libboard_zynq = { path = "../libboard_zynq" }
|
||||||
core_io = { version = "0.1", features = ["collections"] }
|
|
||||||
fatfs = { version = "0.3", features = ["core_io"], default-features = false }
|
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|
||||||
|
[dependencies.fatfs]
|
||||||
|
git = "https://github.com/rafalh/rust-fatfs"
|
||||||
|
rev = "85f06e0"
|
||||||
|
default-features = false
|
||||||
|
features = ["alloc", "lfn"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
target_zc706 = []
|
target_zc706 = []
|
||||||
target_coraz7 = []
|
target_coraz7 = []
|
||||||
|
@ -17,4 +21,4 @@ target_ebaz4205 = []
|
||||||
target_redpitaya = []
|
target_redpitaya = []
|
||||||
target_kasli_soc = []
|
target_kasli_soc = []
|
||||||
ipv6 = []
|
ipv6 = []
|
||||||
fat_lfn = [ "fatfs/alloc" ]
|
fat_lfn = [ "fatfs/alloc" ]
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
use core_io::{Error, Read, Seek, SeekFrom};
|
use fatfs::{self, Read, Seek, SeekFrom};
|
||||||
use libboard_zynq::devc;
|
use libboard_zynq::devc;
|
||||||
|
use crate::sd_reader;
|
||||||
|
use crate::File;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
|
|
||||||
|
type Error = fatfs::Error<sd_reader::Error>;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum BootgenLoadingError {
|
pub enum BootgenLoadingError {
|
||||||
InvalidBootImageHeader,
|
InvalidBootImageHeader,
|
||||||
|
@ -58,7 +62,7 @@ struct PartitionHeader {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Read a u32 word from the reader.
|
/// Read a u32 word from the reader.
|
||||||
fn read_u32<Reader: Read>(reader: &mut Reader) -> Result<u32, BootgenLoadingError> {
|
fn read_u32<'a>(reader: &mut File<'a>) -> Result<u32, BootgenLoadingError> {
|
||||||
let mut buffer: [u8; 4] = [0; 4];
|
let mut buffer: [u8; 4] = [0; 4];
|
||||||
reader.read_exact(&mut buffer)?;
|
reader.read_exact(&mut buffer)?;
|
||||||
let mut result: u32 = 0;
|
let mut result: u32 = 0;
|
||||||
|
@ -69,8 +73,8 @@ fn read_u32<Reader: Read>(reader: &mut Reader) -> Result<u32, BootgenLoadingErro
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Load PL partition header.
|
/// Load PL partition header.
|
||||||
fn load_pl_header<File: Read + Seek>(
|
fn load_pl_header<'a>(
|
||||||
file: &mut File,
|
file: &mut File<'a>,
|
||||||
) -> Result<Option<PartitionHeader>, BootgenLoadingError> {
|
) -> Result<Option<PartitionHeader>, BootgenLoadingError> {
|
||||||
let mut buffer: [u8; 0x40] = [0; 0x40];
|
let mut buffer: [u8; 0x40] = [0; 0x40];
|
||||||
file.read_exact(&mut buffer)?;
|
file.read_exact(&mut buffer)?;
|
||||||
|
@ -82,8 +86,8 @@ fn load_pl_header<File: Read + Seek>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_ps_header<File: Read + Seek>(
|
fn load_ps_header<'a>(
|
||||||
file: &mut File,
|
file: &mut File<'a>,
|
||||||
) -> Result<Option<PartitionHeader>, BootgenLoadingError> {
|
) -> Result<Option<PartitionHeader>, BootgenLoadingError> {
|
||||||
let mut buffer: [u8; 0x40] = [0; 0x40];
|
let mut buffer: [u8; 0x40] = [0; 0x40];
|
||||||
file.read_exact(&mut buffer)?;
|
file.read_exact(&mut buffer)?;
|
||||||
|
@ -98,10 +102,10 @@ fn load_ps_header<File: Read + Seek>(
|
||||||
/// Locate the partition from the image, and return the size (in bytes) of the partition if successful.
|
/// Locate the partition from the image, and return the size (in bytes) of the partition if successful.
|
||||||
/// This function would seek the file to the location of the partition.
|
/// This function would seek the file to the location of the partition.
|
||||||
fn locate<
|
fn locate<
|
||||||
File: Read + Seek,
|
'a,
|
||||||
F: Fn(&mut File) -> Result<Option<PartitionHeader>, BootgenLoadingError>,
|
F: Fn(&mut File<'a>) -> Result<Option<PartitionHeader>, BootgenLoadingError>,
|
||||||
>(
|
>(
|
||||||
file: &mut File,
|
file: &mut File<'a>,
|
||||||
f: F,
|
f: F,
|
||||||
) -> Result<usize, BootgenLoadingError> {
|
) -> Result<usize, BootgenLoadingError> {
|
||||||
file.seek(SeekFrom::Start(0))?;
|
file.seek(SeekFrom::Start(0))?;
|
||||||
|
@ -149,7 +153,7 @@ fn locate<
|
||||||
/// Load bitstream from bootgen file.
|
/// Load bitstream from bootgen file.
|
||||||
/// This function parses the file, locate the bitstream and load it through the PCAP driver.
|
/// This function parses the file, locate the bitstream and load it through the PCAP driver.
|
||||||
/// It requires a large buffer, please enable the DDR RAM before using it.
|
/// It requires a large buffer, please enable the DDR RAM before using it.
|
||||||
pub fn load_bitstream<File: Read + Seek>(file: &mut File) -> Result<(), BootgenLoadingError> {
|
pub fn load_bitstream<'a>(file: &mut File<'a>) -> Result<(), BootgenLoadingError> {
|
||||||
let size = locate(file, load_pl_header)?;
|
let size = locate(file, load_pl_header)?;
|
||||||
unsafe {
|
unsafe {
|
||||||
// align to 64 bytes
|
// align to 64 bytes
|
||||||
|
@ -170,7 +174,7 @@ pub fn load_bitstream<File: Read + Seek>(file: &mut File) -> Result<(), BootgenL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_runtime<File: Read + Seek>(file: &mut File) -> Result<Vec<u8>, BootgenLoadingError> {
|
pub fn get_runtime<'a>(file: &mut File<'a>) -> Result<Vec<u8>, BootgenLoadingError> {
|
||||||
let size = locate(file, load_ps_header)?;
|
let size = locate(file, load_ps_header)?;
|
||||||
let mut buffer = Vec::with_capacity(size);
|
let mut buffer = Vec::with_capacity(size);
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -1,19 +1,24 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
use core::fmt;
|
use alloc::{rc::Rc, string::{FromUtf8Error, String}, vec::Vec};
|
||||||
use alloc::{string::FromUtf8Error, string::String, vec::Vec, rc::Rc};
|
use sd_reader::SdReader;
|
||||||
use core_io::{self as io, BufRead, BufReader, Read, Write, Seek, SeekFrom};
|
use core::{cmp, fmt};
|
||||||
|
use fatfs::{self, Read, Seek, SeekFrom, Write};
|
||||||
use libboard_zynq::sdio;
|
use libboard_zynq::sdio;
|
||||||
|
|
||||||
pub mod sd_reader;
|
|
||||||
pub mod net_settings;
|
|
||||||
pub mod bootgen;
|
pub mod bootgen;
|
||||||
|
pub mod net_settings;
|
||||||
|
pub mod sd_reader;
|
||||||
|
|
||||||
|
type SdReadError = fatfs::Error<sd_reader::Error>;
|
||||||
|
|
||||||
|
pub type File<'a> = fatfs::File<'a, SdReader, fatfs::NullTimeProvider, fatfs::LossyOemCpConverter>;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error<'a> {
|
pub enum Error<'a> {
|
||||||
SdError(sdio::sd_card::CardInitializationError),
|
SdError(sdio::sd_card::CardInitializationError),
|
||||||
IoError(io::Error),
|
IoError(SdReadError),
|
||||||
Utf8Error(FromUtf8Error),
|
Utf8Error(FromUtf8Error),
|
||||||
KeyNotFoundError(&'a str),
|
KeyNotFoundError(&'a str),
|
||||||
NoConfig,
|
NoConfig,
|
||||||
|
@ -39,8 +44,8 @@ impl<'a> From<sdio::sd_card::CardInitializationError> for Error<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<io::Error> for Error<'a> {
|
impl<'a> From<SdReadError> for Error<'a> {
|
||||||
fn from(error: io::Error) -> Self {
|
fn from(error: SdReadError) -> Self {
|
||||||
Error::IoError(error)
|
Error::IoError(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,14 +56,60 @@ impl<'a> From<FromUtf8Error> for Error<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Simplified replacements to `read_to_end` and `read_to_string` from core_io
|
||||||
|
fn read_to_end<'a>(file: &mut File<'a>, buffer: &mut Vec<u8>) -> Result<'a, usize> {
|
||||||
|
const PROBE_SIZE: usize = 32;
|
||||||
|
const MAX_READ_SIZE: usize = 512; // read max BLOCK_SIZE at a time
|
||||||
|
let start_len = buffer.len();
|
||||||
|
let start_cap = buffer.capacity();
|
||||||
|
fn small_probe_read<'a>(file: &mut File<'a>, buffer: &mut Vec<u8>) -> Result<'a, usize> {
|
||||||
|
let mut probe = [0u8; PROBE_SIZE];
|
||||||
|
let n = file.read(&mut probe)?;
|
||||||
|
buffer.extend_from_slice(&probe[..n]);
|
||||||
|
Ok(n)
|
||||||
|
}
|
||||||
|
if start_cap - start_len < PROBE_SIZE {
|
||||||
|
let read = small_probe_read(file, buffer)?;
|
||||||
|
if read == 0 {
|
||||||
|
return Ok(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
loop {
|
||||||
|
if buffer.len() == buffer.capacity() && buffer.capacity() == start_cap {
|
||||||
|
let read = small_probe_read(file, buffer)?;
|
||||||
|
if read == 0 {
|
||||||
|
return Ok(buffer.len() - start_len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if buffer.len() == buffer.capacity() {
|
||||||
|
buffer.try_reserve(PROBE_SIZE).unwrap();
|
||||||
|
}
|
||||||
|
let mut read_buf = [0u8; MAX_READ_SIZE];
|
||||||
|
let buf_len = cmp::min(MAX_READ_SIZE, buffer.capacity() - buffer.len());
|
||||||
|
let mut read_buf_mut = &mut read_buf[..buf_len];
|
||||||
|
let bytes_read = file.read(&mut read_buf_mut)?;
|
||||||
|
if bytes_read == 0 {
|
||||||
|
return Ok(buffer.len() - start_len);
|
||||||
|
}
|
||||||
|
buffer.extend_from_slice(&read_buf_mut[..bytes_read]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_to_string<'a>(file: &mut File<'a>) -> Result<'a, String> {
|
||||||
|
let mut buffer: Vec<u8> = Vec::new();
|
||||||
|
read_to_end(file, &mut buffer).map(|_| ())?;
|
||||||
|
Ok(String::from_utf8(buffer)?)
|
||||||
|
}
|
||||||
|
|
||||||
fn parse_config<'a>(
|
fn parse_config<'a>(
|
||||||
key: &'a str,
|
key: &'a str,
|
||||||
buffer: &mut Vec<u8>,
|
buffer: &mut Vec<u8>,
|
||||||
file: fatfs::File<sd_reader::SdReader>,
|
mut file: File<'a>,
|
||||||
) -> Result<'a, ()> {
|
) -> Result<'a, ()> {
|
||||||
let prefix = [key, "="].concat().to_ascii_lowercase();
|
let prefix = [key, "="].concat().to_ascii_lowercase();
|
||||||
for line in BufReader::new(file).lines() {
|
let read_buffer = read_to_string(&mut file)?;
|
||||||
let line = line?.to_ascii_lowercase();
|
for line in read_buffer.lines() {
|
||||||
|
let line = line.to_ascii_lowercase();
|
||||||
if line.starts_with(&prefix) {
|
if line.starts_with(&prefix) {
|
||||||
buffer.extend(line[prefix.len()..].as_bytes());
|
buffer.extend(line[prefix.len()..].as_bytes());
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
@ -83,7 +134,9 @@ impl Config {
|
||||||
let reader = sd_reader::SdReader::new(sd);
|
let reader = sd_reader::SdReader::new(sd);
|
||||||
|
|
||||||
let fs = reader.mount_fatfs(sd_reader::PartitionEntry::Entry1)?;
|
let fs = reader.mount_fatfs(sd_reader::PartitionEntry::Entry1)?;
|
||||||
Ok(Config { fs: Some(Rc::new(fs)) })
|
Ok(Config {
|
||||||
|
fs: Some(Rc::new(fs)),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_fs(fs: Option<Rc<fatfs::FileSystem<sd_reader::SdReader>>>) -> Self {
|
pub fn from_fs(fs: Option<Rc<fatfs::FileSystem<sd_reader::SdReader>>>) -> Self {
|
||||||
|
@ -94,12 +147,12 @@ impl Config {
|
||||||
Config { fs: None }
|
Config { fs: None }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read<'b>(&self, key: &'b str) -> Result<'b, Vec<u8>> {
|
pub fn read<'b>(&'b self, key: &'b str) -> Result<'b, Vec<u8>> {
|
||||||
if let Some(fs) = &self.fs {
|
if let Some(fs) = &self.fs {
|
||||||
let root_dir = fs.root_dir();
|
let root_dir = fs.root_dir();
|
||||||
let mut buffer: Vec<u8> = Vec::new();
|
let mut buffer: Vec<u8> = Vec::new();
|
||||||
match root_dir.open_file(&["/CONFIG/", key, ".BIN"].concat()) {
|
match root_dir.open_file(&["/CONFIG/", key, ".BIN"].concat()) {
|
||||||
Ok(mut f) => f.read_to_end(&mut buffer).map(|_| ())?,
|
Ok(mut f) => read_to_end( &mut f, &mut buffer).map(|_| ())?,
|
||||||
Err(_) => match root_dir.open_file("/CONFIG.TXT") {
|
Err(_) => match root_dir.open_file("/CONFIG.TXT") {
|
||||||
Ok(f) => parse_config(key, &mut buffer, f)?,
|
Ok(f) => parse_config(key, &mut buffer, f)?,
|
||||||
Err(_) => return Err(Error::KeyNotFoundError(key)),
|
Err(_) => return Err(Error::KeyNotFoundError(key)),
|
||||||
|
@ -111,11 +164,11 @@ impl Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_str<'b>(&self, key: &'b str) -> Result<'b, String> {
|
pub fn read_str<'b>(&'b self, key: &'b str) -> Result<'b, String> {
|
||||||
Ok(String::from_utf8(self.read(key)?)?)
|
Ok(String::from_utf8(self.read(key)?)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove<'b>(&self, key: &'b str) -> Result<'b, ()> {
|
pub fn remove<'b>(&'b self, key: &'b str) -> Result<'b, ()> {
|
||||||
if let Some(fs) = &self.fs {
|
if let Some(fs) = &self.fs {
|
||||||
let root_dir = fs.root_dir();
|
let root_dir = fs.root_dir();
|
||||||
match root_dir.remove(&["/CONFIG/", key, ".BIN"].concat()) {
|
match root_dir.remove(&["/CONFIG/", key, ".BIN"].concat()) {
|
||||||
|
@ -124,19 +177,19 @@ impl Config {
|
||||||
let prefix = [key, "="].concat().to_ascii_lowercase();
|
let prefix = [key, "="].concat().to_ascii_lowercase();
|
||||||
match root_dir.create_file("/CONFIG.TXT") {
|
match root_dir.create_file("/CONFIG.TXT") {
|
||||||
Ok(mut f) => {
|
Ok(mut f) => {
|
||||||
let mut buffer = String::new();
|
let buffer = read_to_string(&mut f)?;
|
||||||
f.read_to_string(&mut buffer)?;
|
|
||||||
f.seek(SeekFrom::Start(0))?;
|
f.seek(SeekFrom::Start(0))?;
|
||||||
f.truncate()?;
|
f.truncate()?;
|
||||||
for line in buffer.lines() {
|
for line in buffer.lines() {
|
||||||
if line.len() > 0 && !line.to_ascii_lowercase().starts_with(&prefix) {
|
if line.len() > 0 && !line.to_ascii_lowercase().starts_with(&prefix)
|
||||||
|
{
|
||||||
f.write(line.as_bytes())?;
|
f.write(line.as_bytes())?;
|
||||||
f.write(NEWLINE)?;
|
f.write(NEWLINE)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
}
|
||||||
Err(_) => Err(Error::KeyNotFoundError(key))
|
Err(_) => Err(Error::KeyNotFoundError(key)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,7 +215,10 @@ impl Config {
|
||||||
if is_str {
|
if is_str {
|
||||||
let mut f = root_dir.create_file("/CONFIG.TXT")?;
|
let mut f = root_dir.create_file("/CONFIG.TXT")?;
|
||||||
f.seek(SeekFrom::End(0))?;
|
f.seek(SeekFrom::End(0))?;
|
||||||
write!(f, "{}={}\n", key, String::from_utf8(value).unwrap())?;
|
f.write(key.as_bytes())?;
|
||||||
|
f.write("=".as_bytes())?;
|
||||||
|
f.write(value.as_slice())?;
|
||||||
|
f.write(NEWLINE)?;
|
||||||
} else {
|
} else {
|
||||||
let dir = root_dir.create_dir("/CONFIG")?;
|
let dir = root_dir.create_dir("/CONFIG")?;
|
||||||
let mut f = dir.create_file(&[key, ".BIN"].concat())?;
|
let mut f = dir.create_file(&[key, ".BIN"].concat())?;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use core_io::{BufRead, Error, ErrorKind, Read, Result as IoResult, Seek, SeekFrom, Write};
|
use alloc::vec::Vec;
|
||||||
use fatfs;
|
use core::fmt;
|
||||||
|
use fatfs::{self, IoBase, IoError, Read, Seek, SeekFrom, Write};
|
||||||
use libboard_zynq::sdio::{sd_card::SdCard, CmdTransferError};
|
use libboard_zynq::sdio::{sd_card::SdCard, CmdTransferError};
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use alloc::vec::Vec;
|
|
||||||
|
|
||||||
const MBR_SIGNATURE: [u8; 2] = [0x55, 0xAA];
|
const MBR_SIGNATURE: [u8; 2] = [0x55, 0xAA];
|
||||||
const PARTID_FAT12: u8 = 0x01;
|
const PARTID_FAT12: u8 = 0x01;
|
||||||
|
@ -12,13 +12,46 @@ const PARTID_FAT32: u8 = 0x0B;
|
||||||
const PARTID_FAT32_LBA: u8 = 0x0C;
|
const PARTID_FAT32_LBA: u8 = 0x0C;
|
||||||
const PARTID_FAT16_LBA: u8 = 0x0E;
|
const PARTID_FAT16_LBA: u8 = 0x0E;
|
||||||
|
|
||||||
fn cmd_error_to_io_error(_: CmdTransferError) -> Error {
|
|
||||||
Error::new(ErrorKind::Other, "Command transfer error")
|
|
||||||
}
|
|
||||||
|
|
||||||
const BLOCK_SIZE: usize = 512;
|
const BLOCK_SIZE: usize = 512;
|
||||||
|
|
||||||
/// SdReader struct implementing `Read + BufRead + Write + Seek` traits for `core_io`.
|
#[derive(Debug)]
|
||||||
|
pub struct Error {
|
||||||
|
message: &'static str,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Error {
|
||||||
|
pub fn new(message: &'static str) -> Self {
|
||||||
|
Self { message: message }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for Error {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
write!(f, "{}", self.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl IoError for Error {
|
||||||
|
fn is_interrupted(&self) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
fn new_unexpected_eof_error() -> Self {
|
||||||
|
Error::new("Unexpected end of file error")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn new_write_zero_error() -> Self {
|
||||||
|
Error::new("Write zero error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<CmdTransferError> for Error {
|
||||||
|
fn from(_: CmdTransferError) -> Self {
|
||||||
|
Error::new("Command transfer error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// SdReader struct implementing `Read + Write + Seek` traits for `core_io`.
|
||||||
/// Used as an adaptor for fatfs crate, but could be used directly for raw data access.
|
/// Used as an adaptor for fatfs crate, but could be used directly for raw data access.
|
||||||
///
|
///
|
||||||
/// Implementation: all read/writes would be split into unaligned and block-aligned parts,
|
/// Implementation: all read/writes would be split into unaligned and block-aligned parts,
|
||||||
|
@ -43,6 +76,10 @@ pub struct SdReader {
|
||||||
offset: u32,
|
offset: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl IoBase for SdReader {
|
||||||
|
type Error = Error;
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
// Partition entry enum, normally we would use entry1.
|
// Partition entry enum, normally we would use entry1.
|
||||||
|
@ -72,7 +109,7 @@ impl SdReader {
|
||||||
|
|
||||||
/// Internal read function for unaligned read.
|
/// Internal read function for unaligned read.
|
||||||
/// The read must not cross block boundary.
|
/// The read must not cross block boundary.
|
||||||
fn read_unaligned(&mut self, buf: &mut [u8]) -> IoResult<usize> {
|
fn read_unaligned(&mut self, buf: &mut [u8]) -> Result<usize, Error> {
|
||||||
if buf.len() == 0 {
|
if buf.len() == 0 {
|
||||||
return Ok(0);
|
return Ok(0);
|
||||||
}
|
}
|
||||||
|
@ -86,7 +123,7 @@ impl SdReader {
|
||||||
|
|
||||||
/// Internal write function for unaligned write.
|
/// Internal write function for unaligned write.
|
||||||
/// The write must not cross block boundary.
|
/// The write must not cross block boundary.
|
||||||
fn write_unaligned(&mut self, buf: &[u8]) -> IoResult<usize> {
|
fn write_unaligned(&mut self, buf: &[u8]) -> Result<usize, Error> {
|
||||||
if buf.len() == 0 {
|
if buf.len() == 0 {
|
||||||
return Ok(0);
|
return Ok(0);
|
||||||
}
|
}
|
||||||
|
@ -137,7 +174,7 @@ impl SdReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the base offset of the SD card, to transform from physical address to logical address.
|
/// Set the base offset of the SD card, to transform from physical address to logical address.
|
||||||
fn set_base_offset(&mut self, offset: u32) -> IoResult<u64> {
|
fn set_base_offset(&mut self, offset: u32) -> Result<u64, Error> {
|
||||||
self.offset = offset;
|
self.offset = offset;
|
||||||
self.seek(SeekFrom::Start(0))
|
self.seek(SeekFrom::Start(0))
|
||||||
}
|
}
|
||||||
|
@ -145,29 +182,28 @@ impl SdReader {
|
||||||
/// Mount fatfs from partition entry, and return the fatfs object if success.
|
/// Mount fatfs from partition entry, and return the fatfs object if success.
|
||||||
/// This takes the ownership of self, so currently there is no way to recover from an error,
|
/// This takes the ownership of self, so currently there is no way to recover from an error,
|
||||||
/// except creating a new SD card instance.
|
/// except creating a new SD card instance.
|
||||||
pub fn mount_fatfs(mut self, entry: PartitionEntry) -> IoResult<fatfs::FileSystem<Self>> {
|
pub fn mount_fatfs(
|
||||||
|
mut self,
|
||||||
|
entry: PartitionEntry,
|
||||||
|
) -> Result<fatfs::FileSystem<Self>, fatfs::Error<Error>> {
|
||||||
let mut buffer: [u8; 4] = [0; 4];
|
let mut buffer: [u8; 4] = [0; 4];
|
||||||
self.seek(SeekFrom::Start(0x1FE))?;
|
self.seek(SeekFrom::Start(0x1FE))?;
|
||||||
self.read_exact(&mut buffer[..2])?;
|
self.read_exact(&mut buffer[..2])?;
|
||||||
// check MBR signature
|
// check MBR signature
|
||||||
if buffer[..2] != MBR_SIGNATURE {
|
if buffer[..2] != MBR_SIGNATURE {
|
||||||
return Err(Error::new(
|
return Err(fatfs::Error::Io(Error::new("Incorrect signature for MBR sector.")));
|
||||||
ErrorKind::InvalidData,
|
|
||||||
"Incorrect signature for MBR sector.",
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
// Read partition ID.
|
// Read partition ID.
|
||||||
self.seek(SeekFrom::Start(entry as u64 + 0x4))?;
|
self.seek(SeekFrom::Start(entry as u64 + 0x4))?;
|
||||||
self.read_exact(&mut buffer[..1])?;
|
self.read_exact(&mut buffer[..1])?;
|
||||||
debug!("Partition ID: {:0X}", buffer[0]);
|
debug!("Partition ID: {:0X}", buffer[0]);
|
||||||
match buffer[0] {
|
match buffer[0] {
|
||||||
PARTID_FAT12 | PARTID_FAT16_LESS32M | PARTID_FAT16 |
|
PARTID_FAT12 | PARTID_FAT16_LESS32M | PARTID_FAT16 | PARTID_FAT16_LBA
|
||||||
PARTID_FAT16_LBA | PARTID_FAT32 | PARTID_FAT32_LBA => {}
|
| PARTID_FAT32 | PARTID_FAT32_LBA => {}
|
||||||
_ => {
|
_ => {
|
||||||
return Err(Error::new(
|
return Err(fatfs::Error::Io(Error::new(
|
||||||
ErrorKind::InvalidData,
|
|
||||||
"No FAT partition found for the specified entry.",
|
"No FAT partition found for the specified entry.",
|
||||||
));
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Read LBA
|
// Read LBA
|
||||||
|
@ -183,10 +219,29 @@ impl SdReader {
|
||||||
// setup fatfs
|
// setup fatfs
|
||||||
fatfs::FileSystem::new(self, fatfs::FsOptions::new())
|
fatfs::FileSystem::new(self, fatfs::FsOptions::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn fill_buf(&mut self) -> Result<&[u8], Error> {
|
||||||
|
if self.index == BLOCK_SIZE {
|
||||||
|
// flush the buffer if it is dirty before overwriting it with new data
|
||||||
|
if self.dirty {
|
||||||
|
self.flush()?;
|
||||||
|
}
|
||||||
|
// reload buffer
|
||||||
|
self.sd
|
||||||
|
.read_block(self.byte_addr / (BLOCK_SIZE as u32), 1, &mut self.buffer)?;
|
||||||
|
self.index = (self.byte_addr as usize) % BLOCK_SIZE;
|
||||||
|
}
|
||||||
|
Ok(&self.buffer[self.index..])
|
||||||
|
}
|
||||||
|
|
||||||
|
fn consume(&mut self, amt: usize) {
|
||||||
|
self.index += amt;
|
||||||
|
self.byte_addr += amt as u32;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Read for SdReader {
|
impl Read for SdReader {
|
||||||
fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> {
|
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error> {
|
||||||
let total_length = buf.len();
|
let total_length = buf.len();
|
||||||
let (a, b, c) = self.block_align_mut(buf);
|
let (a, b, c) = self.block_align_mut(buf);
|
||||||
self.read_unaligned(a)?;
|
self.read_unaligned(a)?;
|
||||||
|
@ -211,30 +266,8 @@ impl Read for SdReader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BufRead for SdReader {
|
|
||||||
fn fill_buf(&mut self) -> IoResult<&[u8]> {
|
|
||||||
if self.index == BLOCK_SIZE {
|
|
||||||
// flush the buffer if it is dirty before overwriting it with new data
|
|
||||||
if self.dirty {
|
|
||||||
self.flush()?;
|
|
||||||
}
|
|
||||||
// reload buffer
|
|
||||||
self.sd
|
|
||||||
.read_block(self.byte_addr / (BLOCK_SIZE as u32), 1, &mut self.buffer)
|
|
||||||
.map_err(cmd_error_to_io_error)?;
|
|
||||||
self.index = (self.byte_addr as usize) % BLOCK_SIZE;
|
|
||||||
}
|
|
||||||
Ok(&self.buffer[self.index..])
|
|
||||||
}
|
|
||||||
|
|
||||||
fn consume(&mut self, amt: usize) {
|
|
||||||
self.index += amt;
|
|
||||||
self.byte_addr += amt as u32;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Write for SdReader {
|
impl Write for SdReader {
|
||||||
fn write(&mut self, buf: &[u8]) -> IoResult<usize> {
|
fn write(&mut self, buf: &[u8]) -> Result<usize, Error> {
|
||||||
let (a, b, c) = self.block_align(buf);
|
let (a, b, c) = self.block_align(buf);
|
||||||
self.write_unaligned(a)?;
|
self.write_unaligned(a)?;
|
||||||
if b.len() > 0 {
|
if b.len() > 0 {
|
||||||
|
@ -255,12 +288,10 @@ impl Write for SdReader {
|
||||||
Ok(buf.len())
|
Ok(buf.len())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flush(&mut self) -> IoResult<()> {
|
fn flush(&mut self) -> Result<(), Error> {
|
||||||
if self.dirty {
|
if self.dirty {
|
||||||
let block_addr = (self.byte_addr - self.index as u32) / (BLOCK_SIZE as u32);
|
let block_addr = (self.byte_addr - self.index as u32) / (BLOCK_SIZE as u32);
|
||||||
self.sd
|
self.sd.write_block(block_addr, 1, &self.buffer)?;
|
||||||
.write_block(block_addr, 1, &self.buffer)
|
|
||||||
.map_err(cmd_error_to_io_error)?;
|
|
||||||
self.dirty = false;
|
self.dirty = false;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -268,14 +299,14 @@ impl Write for SdReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Seek for SdReader {
|
impl Seek for SdReader {
|
||||||
fn seek(&mut self, pos: SeekFrom) -> IoResult<u64> {
|
fn seek(&mut self, pos: SeekFrom) -> Result<u64, Error> {
|
||||||
let raw_target = match pos {
|
let raw_target = match pos {
|
||||||
SeekFrom::Start(x) => self.offset as i64 + x as i64,
|
SeekFrom::Start(x) => self.offset as i64 + x as i64,
|
||||||
SeekFrom::Current(x) => self.byte_addr as i64 + x,
|
SeekFrom::Current(x) => self.byte_addr as i64 + x,
|
||||||
SeekFrom::End(_) => panic!("SD card does not support seek from end"),
|
SeekFrom::End(_) => panic!("SD card does not support seek from end"),
|
||||||
};
|
};
|
||||||
if raw_target < self.offset as i64 || raw_target > core::u32::MAX as i64 {
|
if raw_target < self.offset as i64 || raw_target > core::u32::MAX as i64 {
|
||||||
return Err(Error::new(ErrorKind::InvalidInput, "Invalid address"));
|
return Err(Error::new("Invalid address"));
|
||||||
}
|
}
|
||||||
let target_byte_addr = raw_target as u32;
|
let target_byte_addr = raw_target as u32;
|
||||||
let address_same_block =
|
let address_same_block =
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
name = "libcortex_a9"
|
name = "libcortex_a9"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
authors = ["M-Labs"]
|
authors = ["M-Labs"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
power_saving = []
|
power_saving = []
|
||||||
|
|
|
@ -1,59 +1,60 @@
|
||||||
|
use core::arch::asm;
|
||||||
|
|
||||||
/// The classic no-op
|
/// The classic no-op
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn nop() {
|
pub fn nop() {
|
||||||
unsafe { llvm_asm!("nop" :::: "volatile") }
|
unsafe { asm!("nop") }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wait For Event
|
/// Wait For Event
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn wfe() {
|
pub fn wfe() {
|
||||||
unsafe { llvm_asm!("wfe" :::: "volatile") }
|
unsafe { asm!("wfe") }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send Event
|
/// Send Event
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn sev() {
|
pub fn sev() {
|
||||||
unsafe { llvm_asm!("sev" :::: "volatile") }
|
unsafe { asm!("sev") }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Data Memory Barrier
|
/// Data Memory Barrier
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn dmb() {
|
pub fn dmb() {
|
||||||
unsafe { llvm_asm!("dmb" :::: "volatile") }
|
unsafe { asm!("dmb") }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Data Synchronization Barrier
|
/// Data Synchronization Barrier
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn dsb() {
|
pub fn dsb() {
|
||||||
unsafe { llvm_asm!("dsb" :::: "volatile") }
|
unsafe { asm!("dsb") }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Instruction Synchronization Barrier
|
/// Instruction Synchronization Barrier
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn isb() {
|
pub fn isb() {
|
||||||
unsafe { llvm_asm!("isb" :::: "volatile") }
|
unsafe { asm!("isb") }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Enable FIQ
|
/// Enable FIQ
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn enable_fiq() {
|
pub unsafe fn enable_fiq() {
|
||||||
llvm_asm!("cpsie f":::: "volatile");
|
asm!("cpsie f");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Enable IRQ
|
/// Enable IRQ
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn enable_irq() {
|
pub unsafe fn enable_irq() {
|
||||||
llvm_asm!("cpsie i":::: "volatile");
|
asm!("cpsie i");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Disable IRQ, return if IRQ was originally enabled.
|
/// Disable IRQ, return if IRQ was originally enabled.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn enter_critical() -> bool {
|
pub unsafe fn enter_critical() -> bool {
|
||||||
let mut cpsr: u32;
|
let mut cpsr: u32;
|
||||||
llvm_asm!(
|
asm!(
|
||||||
"mrs $0, cpsr
|
"mrs {}, cpsr
|
||||||
cpsid i"
|
cpsid i", lateout(reg) cpsr);
|
||||||
: "=r"(cpsr) ::: "volatile");
|
|
||||||
(cpsr & (1 << 7)) == 0
|
(cpsr & (1 << 7)) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,18 +66,18 @@ pub unsafe fn exit_critical(enable: bool) {
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
llvm_asm!(
|
asm!(
|
||||||
"mrs r1, cpsr
|
"mrs r1, cpsr
|
||||||
bic r1, r1, $0
|
bic r1, r1, {}
|
||||||
msr cpsr_c, r1"
|
msr cpsr_c, r1"
|
||||||
:: "r"(mask) : "r1");
|
, in(reg) mask, out("r1") _);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Exiting IRQ
|
/// Exiting IRQ
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn exit_irq() {
|
pub unsafe fn exit_irq() {
|
||||||
llvm_asm!("
|
asm!("
|
||||||
mrs r0, SPSR
|
mrs r0, SPSR
|
||||||
msr CPSR, r0
|
msr CPSR, r0
|
||||||
" ::: "r0");
|
", out("r0") _);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
use super::asm::{dmb, dsb};
|
use super::asm::{dmb, dsb};
|
||||||
use super::l2c::*;
|
use super::l2c::*;
|
||||||
|
use core::arch::asm;
|
||||||
|
|
||||||
/// Invalidate TLBs
|
/// Invalidate TLBs
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn tlbiall() {
|
pub fn tlbiall() {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm_asm!("mcr p15, 0, $0, c8, c7, 0" :: "r" (0) :: "volatile");
|
asm!("mcr p15, 0, {}, c8, c7, 0", in(reg) 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +14,7 @@ pub fn tlbiall() {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn iciallu() {
|
pub fn iciallu() {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm_asm!("mcr p15, 0, $0, c7, c5, 0" :: "r" (0) :: "volatile");
|
asm!("mcr p15, 0, {}, c7, c5, 0", in(reg) 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +22,7 @@ pub fn iciallu() {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn bpiall() {
|
pub fn bpiall() {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm_asm!("mcr p15, 0, $0, c7, c5, 6" :: "r" (0) :: "volatile");
|
asm!("mcr p15, 0, {}, c7, c5, 6", in(reg) 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +30,7 @@ pub fn bpiall() {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn dccsw(setway: u32) {
|
pub fn dccsw(setway: u32) {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm_asm!("mcr p15, 0, $0, c7, c10, 2" :: "r" (setway) :: "volatile");
|
asm!("mcr p15, 0, {}, c7, c10, 2", in(reg) setway);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ pub fn dcisw(setway: u32) {
|
||||||
// also see example code (for DCCISW, but DCISW will be
|
// also see example code (for DCCISW, but DCISW will be
|
||||||
// analogous) "Example code for cache maintenance operations"
|
// analogous) "Example code for cache maintenance operations"
|
||||||
// on pages B2-1286 and B2-1287.
|
// on pages B2-1286 and B2-1287.
|
||||||
llvm_asm!("mcr p15, 0, $0, c7, c6, 2" :: "r" (setway) :: "volatile");
|
asm!("mcr p15, 0, {}, c7, c6, 2", in(reg) setway);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +50,7 @@ pub fn dcisw(setway: u32) {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn dccisw(setway: u32) {
|
pub fn dccisw(setway: u32) {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm_asm!("mcr p15, 0, $0, c7, c14, 2" :: "r" (setway) :: "volatile");
|
asm!("mcr p15, 0, {}, c7, c14, 2", in(reg) setway);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +70,7 @@ pub fn dciall_l1() {
|
||||||
|
|
||||||
// select L1 data cache
|
// select L1 data cache
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm_asm!("mcr p15, 2, $0, c0, c0, 0" :: "r" (0) :: "volatile");
|
asm!("mcr p15, 2, {}, c0, c0, 0", in(reg) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invalidate entire D-Cache by iterating every set and every way
|
// Invalidate entire D-Cache by iterating every set and every way
|
||||||
|
@ -104,7 +105,7 @@ pub fn dcciall_l1() {
|
||||||
|
|
||||||
// select L1 data cache
|
// select L1 data cache
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm_asm!("mcr p15, 2, $0, c0, c0, 0" :: "r" (0) :: "volatile");
|
asm!("mcr p15, 2, {}, c0, c0, 0", in(reg) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invalidate entire D-Cache by iterating every set and every way
|
// Invalidate entire D-Cache by iterating every set and every way
|
||||||
|
@ -156,7 +157,7 @@ fn slice_cache_line_addrs<T>(slice: &[T]) -> impl Iterator<Item = usize> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn dccimvac(addr: usize) {
|
pub fn dccimvac(addr: usize) {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm_asm!("mcr p15, 0, $0, c7, c14, 1" :: "r" (addr) :: "volatile");
|
asm!("mcr p15, 0, {}, c7, c14, 1", in(reg) addr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,10 +199,9 @@ pub fn dcci_slice<T>(slice: &[T]) {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn dccmvac(addr: usize) {
|
pub fn dccmvac(addr: usize) {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm_asm!("mcr p15, 0, $0, c7, c10, 1" :: "r" (addr) :: "volatile");
|
asm!("mcr p15, 0, {}, c7, c10, 1", in(reg) addr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Data cache clean for an object.
|
/// Data cache clean for an object.
|
||||||
pub fn dcc<T>(object: &T) {
|
pub fn dcc<T>(object: &T) {
|
||||||
dmb();
|
dmb();
|
||||||
|
@ -239,7 +239,7 @@ pub fn dcc_slice<T>(slice: &[T]) {
|
||||||
/// affecting more data than intended.
|
/// affecting more data than intended.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn dcimvac(addr: usize) {
|
pub unsafe fn dcimvac(addr: usize) {
|
||||||
llvm_asm!("mcr p15, 0, $0, c7, c6, 1" :: "r" (addr) :: "volatile");
|
asm!("mcr p15, 0, {}, c7, c6, 1", in(reg) addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Data cache clean and invalidate for an object.
|
/// Data cache clean and invalidate for an object.
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
|
use core::arch::asm;
|
||||||
/// Enable FPU in the current core.
|
/// Enable FPU in the current core.
|
||||||
pub fn enable_fpu() {
|
pub fn enable_fpu() {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm_asm!("
|
asm!("
|
||||||
mrc p15, 0, r1, c1, c0, 2
|
mrc p15, 0, r1, c1, c0, 2
|
||||||
orr r1, r1, (0b1111<<20)
|
orr r1, r1, (0b1111<<20)
|
||||||
mcr p15, 0, r1, c1, c0, 2
|
mcr p15, 0, r1, c1, c0, 2
|
||||||
|
@ -9,6 +10,6 @@ pub fn enable_fpu() {
|
||||||
vmrs r1, fpexc
|
vmrs r1, fpexc
|
||||||
orr r1, r1, (1<<30)
|
orr r1, r1, (1<<30)
|
||||||
vmsr fpexc, r1
|
vmsr fpexc, r1
|
||||||
":::"r1");
|
", out("r1") _);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![feature(llvm_asm, global_asm)]
|
|
||||||
#![feature(never_type)]
|
#![feature(never_type)]
|
||||||
#![feature(const_fn)]
|
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
|
@ -17,6 +15,7 @@ pub mod sync_channel;
|
||||||
mod uncached;
|
mod uncached;
|
||||||
pub use fpu::enable_fpu;
|
pub use fpu::enable_fpu;
|
||||||
pub use uncached::UncachedSlice;
|
pub use uncached::UncachedSlice;
|
||||||
|
use core::arch::global_asm;
|
||||||
|
|
||||||
global_asm!(include_str!("exceptions.s"));
|
global_asm!(include_str!("exceptions.s"));
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ use libregister::{
|
||||||
register_bit, register_bits,
|
register_bit, register_bits,
|
||||||
RegisterR, RegisterW, RegisterRW,
|
RegisterR, RegisterW, RegisterRW,
|
||||||
};
|
};
|
||||||
|
use core::arch::asm;
|
||||||
|
|
||||||
macro_rules! def_reg_r {
|
macro_rules! def_reg_r {
|
||||||
($name:tt, $type: ty, $asm_instr:tt) => {
|
($name:tt, $type: ty, $asm_instr:tt) => {
|
||||||
|
@ -11,7 +12,7 @@ macro_rules! def_reg_r {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read(&self) -> Self::R {
|
fn read(&self) -> Self::R {
|
||||||
let mut value: u32;
|
let mut value: u32;
|
||||||
unsafe { llvm_asm!($asm_instr : "=r" (value) ::: "volatile") }
|
unsafe { asm!($asm_instr, lateout(reg) value) }
|
||||||
value.into()
|
value.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +27,7 @@ macro_rules! def_reg_w {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn write(&mut self, value: Self::W) {
|
fn write(&mut self, value: Self::W) {
|
||||||
let value: u32 = value.into();
|
let value: u32 = value.into();
|
||||||
unsafe { llvm_asm!($asm_instr :: "r" (value) :: "volatile") }
|
unsafe { asm!($asm_instr, in(reg) value) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -71,29 +72,29 @@ macro_rules! wrap_reg {
|
||||||
|
|
||||||
/// Stack Pointer
|
/// Stack Pointer
|
||||||
pub struct SP;
|
pub struct SP;
|
||||||
def_reg_r!(SP, u32, "mov $0, sp");
|
def_reg_r!(SP, u32, "mov {}, sp");
|
||||||
def_reg_w!(SP, u32, "mov sp, $0");
|
def_reg_w!(SP, u32, "mov sp, {}");
|
||||||
|
|
||||||
/// Link register (function call return address)
|
/// Link register (function call return address)
|
||||||
pub struct LR;
|
pub struct LR;
|
||||||
def_reg_r!(LR, u32, "mov $0, lr");
|
def_reg_r!(LR, u32, "mov {}, lr");
|
||||||
def_reg_w!(LR, u32, "mov lr, $0");
|
def_reg_w!(LR, u32, "mov lr, {}");
|
||||||
|
|
||||||
pub struct VBAR;
|
pub struct VBAR;
|
||||||
def_reg_r!(VBAR, u32, "mrc p15, 0, $0, c12, c0, 0");
|
def_reg_r!(VBAR, u32, "mrc p15, 0, {}, c12, c0, 0");
|
||||||
def_reg_w!(VBAR, u32, "mcr p15, 0, $0, c12, c0, 0");
|
def_reg_w!(VBAR, u32, "mcr p15, 0, {}, c12, c0, 0");
|
||||||
|
|
||||||
pub struct MVBAR;
|
pub struct MVBAR;
|
||||||
def_reg_r!(MVBAR, u32, "mrc p15, 0, $0, c12, c0, 1");
|
def_reg_r!(MVBAR, u32, "mrc p15, 0, {}, c12, c0, 1");
|
||||||
def_reg_w!(MVBAR, u32, "mcr p15, 0, $0, c12, c0, 1");
|
def_reg_w!(MVBAR, u32, "mcr p15, 0, {}, c12, c0, 1");
|
||||||
|
|
||||||
pub struct HVBAR;
|
pub struct HVBAR;
|
||||||
def_reg_r!(HVBAR, u32, "mrc p15, 4, $0, c12, c0, 0");
|
def_reg_r!(HVBAR, u32, "mrc p15, 4, {}, c12, c0, 0");
|
||||||
def_reg_w!(HVBAR, u32, "mcr p15, 4, $0, c12, c0, 0");
|
def_reg_w!(HVBAR, u32, "mcr p15, 4, {}, c12, c0, 0");
|
||||||
|
|
||||||
/// Multiprocess Affinity Register
|
/// Multiprocess Affinity Register
|
||||||
pub struct MPIDR;
|
pub struct MPIDR;
|
||||||
def_reg_r!(MPIDR, mpidr::Read, "mrc p15, 0, $0, c0, c0, 5");
|
def_reg_r!(MPIDR, mpidr::Read, "mrc p15, 0, {}, c0, c0, 5");
|
||||||
wrap_reg!(mpidr);
|
wrap_reg!(mpidr);
|
||||||
register_bits!(mpidr,
|
register_bits!(mpidr,
|
||||||
/// CPU core index
|
/// CPU core index
|
||||||
|
@ -106,15 +107,15 @@ register_bit!(mpidr,
|
||||||
u, 30);
|
u, 30);
|
||||||
|
|
||||||
pub struct DFAR;
|
pub struct DFAR;
|
||||||
def_reg_r!(DFAR, u32, "mrc p15, 0, $0, c6, c0, 0");
|
def_reg_r!(DFAR, u32, "mrc p15, 0, {}, c6, c0, 0");
|
||||||
|
|
||||||
pub struct DFSR;
|
pub struct DFSR;
|
||||||
def_reg_r!(DFSR, u32, "mrc p15, 0, $0, c5, c0, 0");
|
def_reg_r!(DFSR, u32, "mrc p15, 0, {}, c5, c0, 0");
|
||||||
|
|
||||||
pub struct SCTLR;
|
pub struct SCTLR;
|
||||||
wrap_reg!(sctlr);
|
wrap_reg!(sctlr);
|
||||||
def_reg_r!(SCTLR, sctlr::Read, "mrc p15, 0, $0, c1, c0, 0");
|
def_reg_r!(SCTLR, sctlr::Read, "mrc p15, 0, {}, c1, c0, 0");
|
||||||
def_reg_w!(SCTLR, sctlr::Write, "mcr p15, 0, $0, c1, c0, 0");
|
def_reg_w!(SCTLR, sctlr::Write, "mcr p15, 0, {}, c1, c0, 0");
|
||||||
register_bit!(sctlr,
|
register_bit!(sctlr,
|
||||||
/// Enables MMU
|
/// Enables MMU
|
||||||
m, 0);
|
m, 0);
|
||||||
|
@ -147,8 +148,8 @@ register_bit!(sctlr,
|
||||||
/// Auxiliary Control Register
|
/// Auxiliary Control Register
|
||||||
pub struct ACTLR;
|
pub struct ACTLR;
|
||||||
wrap_reg!(actlr);
|
wrap_reg!(actlr);
|
||||||
def_reg_r!(ACTLR, actlr::Read, "mrc p15, 0, $0, c1, c0, 1");
|
def_reg_r!(ACTLR, actlr::Read, "mrc p15, 0, {}, c1, c0, 1");
|
||||||
def_reg_w!(ACTLR, actlr::Write, "mcr p15, 0, $0, c1, c0, 1");
|
def_reg_w!(ACTLR, actlr::Write, "mcr p15, 0, {}, c1, c0, 1");
|
||||||
// SMP bit
|
// SMP bit
|
||||||
register_bit!(actlr, parity_on, 9);
|
register_bit!(actlr, parity_on, 9);
|
||||||
register_bit!(actlr, alloc_one_way, 8);
|
register_bit!(actlr, alloc_one_way, 8);
|
||||||
|
@ -183,17 +184,17 @@ impl ACTLR {
|
||||||
|
|
||||||
/// Domain Access Control Register
|
/// Domain Access Control Register
|
||||||
pub struct DACR;
|
pub struct DACR;
|
||||||
def_reg_r!(DACR, u32, "mrc p15, 0, $0, c3, c0, 0");
|
def_reg_r!(DACR, u32, "mrc p15, 0, {}, c3, c0, 0");
|
||||||
def_reg_w!(DACR, u32, "mcr p15, 0, $0, c3, c0, 0");
|
def_reg_w!(DACR, u32, "mcr p15, 0, {}, c3, c0, 0");
|
||||||
|
|
||||||
/// Translation Table Base Register 0
|
/// Translation Table Base Register 0
|
||||||
pub struct TTBR0;
|
pub struct TTBR0;
|
||||||
/// Translation Table Base Register 1
|
/// Translation Table Base Register 1
|
||||||
pub struct TTBR1;
|
pub struct TTBR1;
|
||||||
def_reg_r!(TTBR0, ttbr::Read, "mrc p15, 0, $0, c2, c0, 0");
|
def_reg_r!(TTBR0, ttbr::Read, "mrc p15, 0, {}, c2, c0, 0");
|
||||||
def_reg_w!(TTBR0, ttbr::Write, "mcr p15, 0, $0, c2, c0, 0");
|
def_reg_w!(TTBR0, ttbr::Write, "mcr p15, 0, {}, c2, c0, 0");
|
||||||
def_reg_r!(TTBR1, ttbr::Read, "mrc p15, 0, $0, c2, c0, 1");
|
def_reg_r!(TTBR1, ttbr::Read, "mrc p15, 0, {}, c2, c0, 1");
|
||||||
def_reg_w!(TTBR1, ttbr::Write, "mcr p15, 0, $0, c2, c0, 1");
|
def_reg_w!(TTBR1, ttbr::Write, "mcr p15, 0, {}, c2, c0, 1");
|
||||||
wrap_reg!(ttbr);
|
wrap_reg!(ttbr);
|
||||||
register_bits!(ttbr, table_base, u32, 14, 31);
|
register_bits!(ttbr, table_base, u32, 14, 31);
|
||||||
register_bit!(ttbr, irgn0, 6);
|
register_bit!(ttbr, irgn0, 6);
|
||||||
|
|
|
@ -172,13 +172,12 @@ impl<'a, T> Iterator for Receiver<'a, T> where T: Clone {
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
/// Macro for initializing the sync_channel with static buffer and indexes.
|
/// Macro for initializing the sync_channel with static buffer and indexes.
|
||||||
/// Note that this requires `#![feature(const_in_array_repeat_expressions)]`
|
|
||||||
macro_rules! sync_channel {
|
macro_rules! sync_channel {
|
||||||
($t: ty, $cap: expr) => {
|
($t: ty, $cap: expr) => {
|
||||||
{
|
{
|
||||||
use core::sync::atomic::{AtomicUsize, AtomicPtr};
|
use core::sync::atomic::{AtomicUsize, AtomicPtr};
|
||||||
use $crate::sync_channel::{Sender, Receiver};
|
use $crate::sync_channel::{Sender, Receiver};
|
||||||
static LIST: [AtomicPtr<$t>; $cap + 1] = [AtomicPtr::new(core::ptr::null_mut()); $cap + 1];
|
static LIST: [AtomicPtr<$t>; $cap + 1] = [const { AtomicPtr::new(core::ptr::null_mut()) }; $cap + 1];
|
||||||
static WRITE: AtomicUsize = AtomicUsize::new(0);
|
static WRITE: AtomicUsize = AtomicUsize::new(0);
|
||||||
static READ: AtomicUsize = AtomicUsize::new(0);
|
static READ: AtomicUsize = AtomicUsize::new(0);
|
||||||
(Sender::new(&LIST, &WRITE, &READ), Receiver::new(&LIST, &WRITE, &READ))
|
(Sender::new(&LIST, &WRITE, &READ), Receiver::new(&LIST, &WRITE, &READ))
|
||||||
|
|
|
@ -33,8 +33,6 @@ impl<T> UncachedSlice<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let slice = unsafe { core::slice::from_raw_parts_mut(ptr, len) };
|
let slice = unsafe { core::slice::from_raw_parts_mut(ptr, len) };
|
||||||
// verify size
|
|
||||||
assert!(unsafe { slice.get_unchecked(len) } as *const _ as usize <= start + size);
|
|
||||||
// initialize
|
// initialize
|
||||||
for e in slice.iter_mut() {
|
for e in slice.iter_mut() {
|
||||||
*e = default();
|
*e = default();
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
name = "libregister"
|
name = "libregister"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
authors = ["M-Labs"]
|
authors = ["M-Labs"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
vcell = "0.1"
|
vcell = "0.1"
|
||||||
|
|
|
@ -3,7 +3,7 @@ name = "libsupport_zynq"
|
||||||
description = "Software support for running in the Zynq PS"
|
description = "Software support for running in the Zynq PS"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
authors = ["M-Labs"]
|
authors = ["M-Labs"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
target_zc706 = ["libboard_zynq/target_zc706"]
|
target_zc706 = ["libboard_zynq/target_zc706"]
|
||||||
|
@ -20,7 +20,7 @@ default = ["panic_handler", "dummy_irq_handler", "dummy_fiq_handler"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
r0 = "1"
|
r0 = "1"
|
||||||
compiler_builtins = "=0.1.39"
|
compiler_builtins = "=0.1.109"
|
||||||
linked_list_allocator = { version = "0.8", default-features = false, features = ["const_mut_refs"] }
|
linked_list_allocator = { version = "0.8", default-features = false, features = ["const_mut_refs"] }
|
||||||
libregister = { path = "../libregister" }
|
libregister = { path = "../libregister" }
|
||||||
libcortex_a9 = { path = "../libcortex_a9" }
|
libcortex_a9 = { path = "../libcortex_a9" }
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use r0::zero_bss;
|
use r0::zero_bss;
|
||||||
use core::ptr::write_volatile;
|
use core::ptr::write_volatile;
|
||||||
|
use core::arch::asm;
|
||||||
use libregister::{
|
use libregister::{
|
||||||
VolatileCell,
|
VolatileCell,
|
||||||
RegisterR, RegisterRW,
|
RegisterR, RegisterRW,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use libregister::{RegisterR, RegisterW};
|
use libregister::{RegisterR, RegisterW};
|
||||||
use libcortex_a9::{regs::{DFSR, MPIDR, VBAR}, interrupt_handler};
|
use libcortex_a9::{regs::{DFSR, MPIDR, VBAR}, interrupt_handler};
|
||||||
use libboard_zynq::{println, stdio};
|
use libboard_zynq::{println, stdio};
|
||||||
|
use core::arch::asm;
|
||||||
|
|
||||||
pub fn set_vector_table(base_addr: u32){
|
pub fn set_vector_table(base_addr: u32){
|
||||||
VBAR.write(base_addr);
|
VBAR.write(base_addr);
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
#![feature(alloc_error_handler)]
|
#![feature(alloc_error_handler)]
|
||||||
#![feature(panic_info_message)]
|
|
||||||
#![feature(naked_functions)]
|
#![feature(naked_functions)]
|
||||||
#![feature(asm)]
|
|
||||||
|
|
||||||
pub extern crate alloc;
|
pub extern crate alloc;
|
||||||
pub extern crate compiler_builtins;
|
pub extern crate compiler_builtins;
|
||||||
|
|
|
@ -10,7 +10,7 @@ fn panic(info: &core::panic::PanicInfo) -> ! {
|
||||||
} else {
|
} else {
|
||||||
print!("unknown location");
|
print!("unknown location");
|
||||||
}
|
}
|
||||||
if let Some(message) = info.message() {
|
if let Some(message) = info.message().as_str() {
|
||||||
println!(": {}", message);
|
println!(": {}", message);
|
||||||
} else {
|
} else {
|
||||||
println!("");
|
println!("");
|
||||||
|
|
|
@ -1,138 +0,0 @@
|
||||||
{ lib, stdenv, llvm_meta, fetch, fetchpatch, substituteAll, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
|
|
||||||
, buildLlvmTools
|
|
||||||
, fixDarwinDylibNames
|
|
||||||
, enableManpages ? false
|
|
||||||
, enablePolly ? false
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
|
||||||
self = stdenv.mkDerivation ({
|
|
||||||
pname = "clang";
|
|
||||||
inherit version;
|
|
||||||
|
|
||||||
src = fetch "clang" "12sm91qx2m79cvj75a9aazf2x8xybjbd593dv6v7rxficpq8i0ha";
|
|
||||||
inherit clang-tools-extra_src;
|
|
||||||
|
|
||||||
unpackPhase = ''
|
|
||||||
unpackFile $src
|
|
||||||
mv clang-* clang
|
|
||||||
sourceRoot=$PWD/clang
|
|
||||||
unpackFile ${clang-tools-extra_src}
|
|
||||||
mv clang-tools-extra-* $sourceRoot/tools/extra
|
|
||||||
'';
|
|
||||||
|
|
||||||
nativeBuildInputs = [ cmake python3 ]
|
|
||||||
++ lib.optional enableManpages python3.pkgs.sphinx
|
|
||||||
++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
|
|
||||||
|
|
||||||
buildInputs = [ libxml2 libllvm ];
|
|
||||||
|
|
||||||
cmakeFlags = [
|
|
||||||
"-DCLANGD_BUILD_XPC=OFF"
|
|
||||||
"-DLLVM_ENABLE_RTTI=ON"
|
|
||||||
] ++ lib.optionals enableManpages [
|
|
||||||
"-DCLANG_INCLUDE_DOCS=ON"
|
|
||||||
"-DLLVM_ENABLE_SPHINX=ON"
|
|
||||||
"-DSPHINX_OUTPUT_MAN=ON"
|
|
||||||
"-DSPHINX_OUTPUT_HTML=OFF"
|
|
||||||
"-DSPHINX_WARNINGS_AS_ERRORS=OFF"
|
|
||||||
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
|
||||||
"-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen"
|
|
||||||
"-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen"
|
|
||||||
] ++ lib.optionals enablePolly [
|
|
||||||
"-DWITH_POLLY=ON"
|
|
||||||
"-DLINK_POLLY_INTO_TOOLS=ON"
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
patches = [
|
|
||||||
./purity.patch
|
|
||||||
# https://reviews.llvm.org/D51899
|
|
||||||
./gnu-install-dirs.patch
|
|
||||||
(substituteAll {
|
|
||||||
src = ../../clang-11-12-LLVMgold-path.patch;
|
|
||||||
libllvmLibdir = "${libllvm.lib}/lib";
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
postPatch = ''
|
|
||||||
sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \
|
|
||||||
-e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' \
|
|
||||||
lib/Driver/ToolChains/*.cpp
|
|
||||||
'' + lib.optionalString stdenv.hostPlatform.isMusl ''
|
|
||||||
sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp
|
|
||||||
'' + lib.optionalString stdenv.hostPlatform.isDarwin ''
|
|
||||||
substituteInPlace tools/extra/clangd/CMakeLists.txt \
|
|
||||||
--replace "NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB" FALSE
|
|
||||||
'';
|
|
||||||
|
|
||||||
outputs = [ "out" "lib" "dev" "python" ];
|
|
||||||
|
|
||||||
postInstall = ''
|
|
||||||
ln -sv $out/bin/clang $out/bin/cpp
|
|
||||||
|
|
||||||
# Move libclang to 'lib' output
|
|
||||||
moveToOutput "lib/libclang.*" "$lib"
|
|
||||||
moveToOutput "lib/libclang-cpp.*" "$lib"
|
|
||||||
substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \
|
|
||||||
--replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \
|
|
||||||
--replace "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp."
|
|
||||||
|
|
||||||
mkdir -p $python/bin $python/share/{clang,scan-view}
|
|
||||||
mv $out/bin/{git-clang-format,scan-view} $python/bin
|
|
||||||
if [ -e $out/bin/set-xcode-analyzer ]; then
|
|
||||||
mv $out/bin/set-xcode-analyzer $python/bin
|
|
||||||
fi
|
|
||||||
mv $out/share/clang/*.py $python/share/clang
|
|
||||||
mv $out/share/scan-view/*.py $python/share/scan-view
|
|
||||||
rm $out/bin/c-index-test
|
|
||||||
patchShebangs $python/bin
|
|
||||||
|
|
||||||
mkdir -p $dev/bin
|
|
||||||
cp bin/clang-tblgen $dev/bin
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru = {
|
|
||||||
inherit libllvm;
|
|
||||||
isClang = true;
|
|
||||||
hardeningUnsupportedFlags = [ "fortify3" ];
|
|
||||||
};
|
|
||||||
|
|
||||||
meta = llvm_meta // {
|
|
||||||
homepage = "https://clang.llvm.org/";
|
|
||||||
description = "A C language family frontend for LLVM";
|
|
||||||
longDescription = ''
|
|
||||||
The Clang project provides a language front-end and tooling
|
|
||||||
infrastructure for languages in the C language family (C, C++, Objective
|
|
||||||
C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project.
|
|
||||||
It aims to deliver amazingly fast compiles, extremely useful error and
|
|
||||||
warning messages and to provide a platform for building great source
|
|
||||||
level tools. The Clang Static Analyzer and clang-tidy are tools that
|
|
||||||
automatically find bugs in your code, and are great examples of the sort
|
|
||||||
of tools that can be built using the Clang frontend as a library to
|
|
||||||
parse C/C++ code.
|
|
||||||
'';
|
|
||||||
mainProgram = "clang";
|
|
||||||
};
|
|
||||||
} // lib.optionalAttrs enableManpages {
|
|
||||||
pname = "clang-manpages";
|
|
||||||
|
|
||||||
buildPhase = ''
|
|
||||||
make docs-clang-man
|
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
mkdir -p $out/share/man/man1
|
|
||||||
# Manually install clang manpage
|
|
||||||
cp docs/man/*.1 $out/share/man/man1/
|
|
||||||
'';
|
|
||||||
|
|
||||||
outputs = [ "out" ];
|
|
||||||
|
|
||||||
doCheck = false;
|
|
||||||
|
|
||||||
meta = llvm_meta // {
|
|
||||||
description = "man page for Clang ${version}";
|
|
||||||
};
|
|
||||||
});
|
|
||||||
in self
|
|
|
@ -1,235 +0,0 @@
|
||||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
||||||
index bb4b801f01c8..77a8b43b22c8 100644
|
|
||||||
--- a/CMakeLists.txt
|
|
||||||
+++ b/CMakeLists.txt
|
|
||||||
@@ -9,6 +9,8 @@ endif()
|
|
||||||
if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
|
|
||||||
project(Clang)
|
|
||||||
|
|
||||||
+ include(GNUInstallDirs)
|
|
||||||
+
|
|
||||||
set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED YES)
|
|
||||||
set(CMAKE_CXX_EXTENSIONS NO)
|
|
||||||
@@ -447,7 +449,7 @@ include_directories(BEFORE
|
|
||||||
|
|
||||||
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
|
|
||||||
install(DIRECTORY include/clang include/clang-c
|
|
||||||
- DESTINATION include
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
|
||||||
COMPONENT clang-headers
|
|
||||||
FILES_MATCHING
|
|
||||||
PATTERN "*.def"
|
|
||||||
@@ -457,7 +459,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
|
|
||||||
)
|
|
||||||
|
|
||||||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/clang
|
|
||||||
- DESTINATION include
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
|
||||||
COMPONENT clang-headers
|
|
||||||
FILES_MATCHING
|
|
||||||
PATTERN "CMakeFiles" EXCLUDE
|
|
||||||
@@ -477,7 +479,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
|
|
||||||
|
|
||||||
add_custom_target(bash-autocomplete DEPENDS utils/bash-autocomplete.sh)
|
|
||||||
install(PROGRAMS utils/bash-autocomplete.sh
|
|
||||||
- DESTINATION share/clang
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/clang
|
|
||||||
COMPONENT bash-autocomplete)
|
|
||||||
if(NOT LLVM_ENABLE_IDE)
|
|
||||||
add_llvm_install_targets(install-bash-autocomplete
|
|
||||||
diff --git a/cmake/modules/AddClang.cmake b/cmake/modules/AddClang.cmake
|
|
||||||
index 704278a0e93b..d25c8d325c71 100644
|
|
||||||
--- a/cmake/modules/AddClang.cmake
|
|
||||||
+++ b/cmake/modules/AddClang.cmake
|
|
||||||
@@ -123,9 +123,9 @@ macro(add_clang_library name)
|
|
||||||
install(TARGETS ${lib}
|
|
||||||
COMPONENT ${lib}
|
|
||||||
${export_to_clangtargets}
|
|
||||||
- LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
|
|
||||||
- ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
|
|
||||||
- RUNTIME DESTINATION bin)
|
|
||||||
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}
|
|
||||||
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}
|
|
||||||
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
|
||||||
|
|
||||||
if (NOT LLVM_ENABLE_IDE)
|
|
||||||
add_llvm_install_targets(install-${lib}
|
|
||||||
@@ -170,7 +170,7 @@ macro(add_clang_tool name)
|
|
||||||
|
|
||||||
install(TARGETS ${name}
|
|
||||||
${export_to_clangtargets}
|
|
||||||
- RUNTIME DESTINATION bin
|
|
||||||
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
||||||
COMPONENT ${name})
|
|
||||||
|
|
||||||
if(NOT LLVM_ENABLE_IDE)
|
|
||||||
@@ -185,7 +185,7 @@ endmacro()
|
|
||||||
macro(add_clang_symlink name dest)
|
|
||||||
add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE)
|
|
||||||
# Always generate install targets
|
|
||||||
- llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE)
|
|
||||||
+ llvm_install_symlink(${name} ${dest} ${CMAKE_INSTALL_FULL_BINDIR} ALWAYS_GENERATE)
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
function(clang_target_link_libraries target type)
|
|
||||||
diff --git a/lib/Headers/CMakeLists.txt b/lib/Headers/CMakeLists.txt
|
|
||||||
index 0692fe75a441..6f201e7207d0 100644
|
|
||||||
--- a/lib/Headers/CMakeLists.txt
|
|
||||||
+++ b/lib/Headers/CMakeLists.txt
|
|
||||||
@@ -208,7 +208,7 @@ set_target_properties(clang-resource-headers PROPERTIES
|
|
||||||
FOLDER "Misc"
|
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${output_dir}")
|
|
||||||
|
|
||||||
-set(header_install_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
|
|
||||||
+set(header_install_dir ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
|
|
||||||
|
|
||||||
install(
|
|
||||||
FILES ${files} ${generated_files}
|
|
||||||
diff --git a/tools/c-index-test/CMakeLists.txt b/tools/c-index-test/CMakeLists.txt
|
|
||||||
index ceef4b08637c..8efad5520ca4 100644
|
|
||||||
--- a/tools/c-index-test/CMakeLists.txt
|
|
||||||
+++ b/tools/c-index-test/CMakeLists.txt
|
|
||||||
@@ -54,7 +54,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
|
|
||||||
set_property(TARGET c-index-test APPEND PROPERTY INSTALL_RPATH
|
|
||||||
"@executable_path/../../lib")
|
|
||||||
else()
|
|
||||||
- set(INSTALL_DESTINATION bin)
|
|
||||||
+ set(INSTALL_DESTINATION ${CMAKE_INSTALL_BINDIR})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
install(TARGETS c-index-test
|
|
||||||
diff --git a/tools/clang-format/CMakeLists.txt b/tools/clang-format/CMakeLists.txt
|
|
||||||
index 35ecdb11253c..d77d75de0094 100644
|
|
||||||
--- a/tools/clang-format/CMakeLists.txt
|
|
||||||
+++ b/tools/clang-format/CMakeLists.txt
|
|
||||||
@@ -21,20 +21,20 @@ if( LLVM_LIB_FUZZING_ENGINE OR LLVM_USE_SANITIZE_COVERAGE )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
install(PROGRAMS clang-format-bbedit.applescript
|
|
||||||
- DESTINATION share/clang
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/clang
|
|
||||||
COMPONENT clang-format)
|
|
||||||
install(PROGRAMS clang-format-diff.py
|
|
||||||
- DESTINATION share/clang
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/clang
|
|
||||||
COMPONENT clang-format)
|
|
||||||
install(PROGRAMS clang-format-sublime.py
|
|
||||||
- DESTINATION share/clang
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/clang
|
|
||||||
COMPONENT clang-format)
|
|
||||||
install(PROGRAMS clang-format.el
|
|
||||||
- DESTINATION share/clang
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/clang
|
|
||||||
COMPONENT clang-format)
|
|
||||||
install(PROGRAMS clang-format.py
|
|
||||||
- DESTINATION share/clang
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/clang
|
|
||||||
COMPONENT clang-format)
|
|
||||||
install(PROGRAMS git-clang-format
|
|
||||||
- DESTINATION bin
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
||||||
COMPONENT clang-format)
|
|
||||||
diff --git a/tools/clang-rename/CMakeLists.txt b/tools/clang-rename/CMakeLists.txt
|
|
||||||
index cda8e29ec5b1..0134d8ccd70b 100644
|
|
||||||
--- a/tools/clang-rename/CMakeLists.txt
|
|
||||||
+++ b/tools/clang-rename/CMakeLists.txt
|
|
||||||
@@ -19,8 +19,8 @@ clang_target_link_libraries(clang-rename
|
|
||||||
)
|
|
||||||
|
|
||||||
install(PROGRAMS clang-rename.py
|
|
||||||
- DESTINATION share/clang
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/clang
|
|
||||||
COMPONENT clang-rename)
|
|
||||||
install(PROGRAMS clang-rename.el
|
|
||||||
- DESTINATION share/clang
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/clang
|
|
||||||
COMPONENT clang-rename)
|
|
||||||
diff --git a/tools/libclang/CMakeLists.txt b/tools/libclang/CMakeLists.txt
|
|
||||||
index 5cd9ac5cddc1..a197676fedbd 100644
|
|
||||||
--- a/tools/libclang/CMakeLists.txt
|
|
||||||
+++ b/tools/libclang/CMakeLists.txt
|
|
||||||
@@ -165,7 +165,7 @@ endif()
|
|
||||||
if(INTERNAL_INSTALL_PREFIX)
|
|
||||||
set(LIBCLANG_HEADERS_INSTALL_DESTINATION "${INTERNAL_INSTALL_PREFIX}/include")
|
|
||||||
else()
|
|
||||||
- set(LIBCLANG_HEADERS_INSTALL_DESTINATION include)
|
|
||||||
+ set(LIBCLANG_HEADERS_INSTALL_DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
install(DIRECTORY ../../include/clang-c
|
|
||||||
@@ -196,7 +196,7 @@ foreach(PythonVersion ${CLANG_PYTHON_BINDINGS_VERSIONS})
|
|
||||||
COMPONENT
|
|
||||||
libclang-python-bindings
|
|
||||||
DESTINATION
|
|
||||||
- "lib${LLVM_LIBDIR_SUFFIX}/python${PythonVersion}/site-packages")
|
|
||||||
+ "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/python${PythonVersion}/site-packages")
|
|
||||||
endforeach()
|
|
||||||
if(NOT LLVM_ENABLE_IDE)
|
|
||||||
add_custom_target(libclang-python-bindings)
|
|
||||||
diff --git a/tools/scan-build/CMakeLists.txt b/tools/scan-build/CMakeLists.txt
|
|
||||||
index ec0702d76f18..d25d982f51da 100644
|
|
||||||
--- a/tools/scan-build/CMakeLists.txt
|
|
||||||
+++ b/tools/scan-build/CMakeLists.txt
|
|
||||||
@@ -47,7 +47,7 @@ if(CLANG_INSTALL_SCANBUILD)
|
|
||||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile})
|
|
||||||
list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile})
|
|
||||||
install(PROGRAMS bin/${BinFile}
|
|
||||||
- DESTINATION bin
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
||||||
COMPONENT scan-build)
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ if(CLANG_INSTALL_SCANBUILD)
|
|
||||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libexec/${LibexecFile})
|
|
||||||
list(APPEND Depends ${CMAKE_BINARY_DIR}/libexec/${LibexecFile})
|
|
||||||
install(PROGRAMS libexec/${LibexecFile}
|
|
||||||
- DESTINATION libexec
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}
|
|
||||||
COMPONENT scan-build)
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ if(CLANG_INSTALL_SCANBUILD)
|
|
||||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/share/scan-build/${ShareFile})
|
|
||||||
list(APPEND Depends ${CMAKE_BINARY_DIR}/share/scan-build/${ShareFile})
|
|
||||||
install(FILES share/scan-build/${ShareFile}
|
|
||||||
- DESTINATION share/scan-build
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/scan-build
|
|
||||||
COMPONENT scan-build)
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
diff --git a/tools/scan-view/CMakeLists.txt b/tools/scan-view/CMakeLists.txt
|
|
||||||
index 22edb974bac7..9f140a9a4538 100644
|
|
||||||
--- a/tools/scan-view/CMakeLists.txt
|
|
||||||
+++ b/tools/scan-view/CMakeLists.txt
|
|
||||||
@@ -22,7 +22,7 @@ if(CLANG_INSTALL_SCANVIEW)
|
|
||||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile})
|
|
||||||
list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile})
|
|
||||||
install(PROGRAMS bin/${BinFile}
|
|
||||||
- DESTINATION bin
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
||||||
COMPONENT scan-view)
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ if(CLANG_INSTALL_SCANVIEW)
|
|
||||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/share/${ShareFile})
|
|
||||||
list(APPEND Depends ${CMAKE_BINARY_DIR}/share/scan-view/${ShareFile})
|
|
||||||
install(FILES share/${ShareFile}
|
|
||||||
- DESTINATION share/scan-view
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/scan-view
|
|
||||||
COMPONENT scan-view)
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
diff --git a/utils/hmaptool/CMakeLists.txt b/utils/hmaptool/CMakeLists.txt
|
|
||||||
index 62f2de0cb15c..6aa66825b6ec 100644
|
|
||||||
--- a/utils/hmaptool/CMakeLists.txt
|
|
||||||
+++ b/utils/hmaptool/CMakeLists.txt
|
|
||||||
@@ -10,7 +10,7 @@ add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/${CLANG_HM
|
|
||||||
|
|
||||||
list(APPEND Depends ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/${CLANG_HMAPTOOL})
|
|
||||||
install(PROGRAMS ${CLANG_HMAPTOOL}
|
|
||||||
- DESTINATION bin
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
||||||
COMPONENT hmaptool)
|
|
||||||
|
|
||||||
add_custom_target(hmaptool ALL DEPENDS ${Depends})
|
|
|
@ -1,28 +0,0 @@
|
||||||
From 4add81bba40dcec62c4ea4481be8e35ac53e89d8 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Will Dietz <w@wdtz.org>
|
|
||||||
Date: Thu, 18 May 2017 11:56:12 -0500
|
|
||||||
Subject: [PATCH] "purity" patch for 5.0
|
|
||||||
|
|
||||||
---
|
|
||||||
lib/Driver/ToolChains/Gnu.cpp | 7 -------
|
|
||||||
1 file changed, 7 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp
|
|
||||||
index fe3c0191bb..c6a482bece 100644
|
|
||||||
--- a/lib/Driver/ToolChains/Gnu.cpp
|
|
||||||
+++ b/lib/Driver/ToolChains/Gnu.cpp
|
|
||||||
@@ -487,12 +487,6 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
|
||||||
if (!IsStatic) {
|
|
||||||
if (Args.hasArg(options::OPT_rdynamic))
|
|
||||||
CmdArgs.push_back("-export-dynamic");
|
|
||||||
-
|
|
||||||
- if (!Args.hasArg(options::OPT_shared) && !IsStaticPIE) {
|
|
||||||
- CmdArgs.push_back("-dynamic-linker");
|
|
||||||
- CmdArgs.push_back(Args.MakeArgString(Twine(D.DyldPrefix) +
|
|
||||||
- ToolChain.getDynamicLinker(Args)));
|
|
||||||
- }
|
|
||||||
}
|
|
||||||
|
|
||||||
CmdArgs.push_back("-o");
|
|
||||||
--
|
|
||||||
2.11.0
|
|
|
@ -1,296 +0,0 @@
|
||||||
{ lowPrio, newScope, pkgs, lib, stdenv, cmake
|
|
||||||
, gccForLibs, preLibcCrossHeaders
|
|
||||||
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
|
|
||||||
, buildLlvmTools # tools, but from the previous stage, for cross
|
|
||||||
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
|
||||||
, targetLlvm
|
|
||||||
# This is the default binutils, but with *this* version of LLD rather
|
|
||||||
# than the default LLVM version's, if LLD is the choice. We use these for
|
|
||||||
# the `useLLVM` bootstrapping below.
|
|
||||||
, bootBintoolsNoLibc ?
|
|
||||||
if stdenv.targetPlatform.linker == "lld"
|
|
||||||
then null
|
|
||||||
else pkgs.bintoolsNoLibc
|
|
||||||
, bootBintools ?
|
|
||||||
if stdenv.targetPlatform.linker == "lld"
|
|
||||||
then null
|
|
||||||
else pkgs.bintools
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
|
||||||
release_version = "11.1.0";
|
|
||||||
candidate = ""; # empty or "rcN"
|
|
||||||
dash-candidate = lib.optionalString (candidate != "") "-${candidate}";
|
|
||||||
version = "${release_version}${dash-candidate}"; # differentiating these (variables) is important for RCs
|
|
||||||
targetConfig = stdenv.targetPlatform.config;
|
|
||||||
|
|
||||||
fetch = name: sha256: fetchurl {
|
|
||||||
url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/${name}-${release_version}${candidate}.src.tar.xz";
|
|
||||||
inherit sha256;
|
|
||||||
};
|
|
||||||
|
|
||||||
clang-tools-extra_src = fetch "clang-tools-extra" "18n1w1hkv931xzq02b34wglbv6zd6sd0r5kb8piwvag7klj7qw3n";
|
|
||||||
|
|
||||||
llvm_meta = {
|
|
||||||
license = lib.licenses.ncsa;
|
|
||||||
|
|
||||||
# See llvm/cmake/config-ix.cmake.
|
|
||||||
platforms =
|
|
||||||
lib.platforms.aarch64 ++
|
|
||||||
lib.platforms.arm ++
|
|
||||||
lib.platforms.mips ++
|
|
||||||
lib.platforms.riscv ++
|
|
||||||
lib.platforms.wasi ++
|
|
||||||
lib.platforms.x86;
|
|
||||||
};
|
|
||||||
|
|
||||||
tools = lib.makeExtensible (tools: let
|
|
||||||
callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch buildLlvmTools; });
|
|
||||||
mkExtraBuildCommands0 = cc: ''
|
|
||||||
rsrc="$out/resource-root"
|
|
||||||
mkdir "$rsrc"
|
|
||||||
ln -s "${cc.lib}/lib/clang/${release_version}/include" "$rsrc"
|
|
||||||
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
|
|
||||||
'';
|
|
||||||
mkExtraBuildCommands = cc: mkExtraBuildCommands0 cc + ''
|
|
||||||
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
|
|
||||||
ln -s "${targetLlvmLibraries.compiler-rt.out}/share" "$rsrc/share"
|
|
||||||
'';
|
|
||||||
|
|
||||||
bintoolsNoLibc' =
|
|
||||||
if bootBintoolsNoLibc == null
|
|
||||||
then tools.bintoolsNoLibc
|
|
||||||
else bootBintoolsNoLibc;
|
|
||||||
bintools' =
|
|
||||||
if bootBintools == null
|
|
||||||
then tools.bintools
|
|
||||||
else bootBintools;
|
|
||||||
|
|
||||||
in {
|
|
||||||
|
|
||||||
libllvm = callPackage ./llvm {
|
|
||||||
inherit llvm_meta;
|
|
||||||
};
|
|
||||||
|
|
||||||
# `llvm` historically had the binaries. When choosing an output explicitly,
|
|
||||||
# we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get*
|
|
||||||
llvm = tools.libllvm;
|
|
||||||
|
|
||||||
libllvm-polly = callPackage ./llvm {
|
|
||||||
inherit llvm_meta;
|
|
||||||
enablePolly = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
llvm-polly = tools.libllvm-polly.lib // { outputSpecified = false; };
|
|
||||||
|
|
||||||
libclang = callPackage ./clang {
|
|
||||||
inherit clang-tools-extra_src llvm_meta;
|
|
||||||
};
|
|
||||||
|
|
||||||
clang-unwrapped = tools.libclang;
|
|
||||||
|
|
||||||
clang-polly-unwrapped = callPackage ./clang {
|
|
||||||
inherit llvm_meta;
|
|
||||||
inherit clang-tools-extra_src;
|
|
||||||
libllvm = tools.libllvm-polly;
|
|
||||||
enablePolly = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
llvm-manpages = lowPrio (tools.libllvm.override {
|
|
||||||
enableManpages = true;
|
|
||||||
python3 = pkgs.python3; # don't use python-boot
|
|
||||||
});
|
|
||||||
|
|
||||||
clang-manpages = lowPrio (tools.libclang.override {
|
|
||||||
enableManpages = true;
|
|
||||||
python3 = pkgs.python3; # don't use python-boot
|
|
||||||
});
|
|
||||||
|
|
||||||
# disabled until recommonmark supports sphinx 3
|
|
||||||
# lldb-manpages = lowPrio (tools.lldb.override {
|
|
||||||
# enableManpages = true;
|
|
||||||
# python3 = pkgs.python3; # don't use python-boot
|
|
||||||
# });
|
|
||||||
|
|
||||||
# pick clang appropriate for package set we are targeting
|
|
||||||
clang =
|
|
||||||
/**/ if stdenv.targetPlatform.libc == null then tools.clangNoLibc
|
|
||||||
else if stdenv.targetPlatform.useLLVM or false then tools.clangUseLLVM
|
|
||||||
else if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU then tools.libstdcxxClang
|
|
||||||
else tools.libcxxClang;
|
|
||||||
|
|
||||||
libstdcxxClang = wrapCCWith rec {
|
|
||||||
cc = tools.clang-unwrapped;
|
|
||||||
# libstdcxx is taken from gcc in an ad-hoc way in cc-wrapper.
|
|
||||||
libcxx = null;
|
|
||||||
extraPackages = [
|
|
||||||
targetLlvmLibraries.compiler-rt
|
|
||||||
];
|
|
||||||
extraBuildCommands = mkExtraBuildCommands cc;
|
|
||||||
};
|
|
||||||
|
|
||||||
libcxxClang = wrapCCWith rec {
|
|
||||||
cc = tools.clang-unwrapped;
|
|
||||||
libcxx = targetLlvmLibraries.libcxx;
|
|
||||||
extraPackages = [
|
|
||||||
libcxx.cxxabi
|
|
||||||
targetLlvmLibraries.compiler-rt
|
|
||||||
];
|
|
||||||
extraBuildCommands = mkExtraBuildCommands cc;
|
|
||||||
};
|
|
||||||
|
|
||||||
lld = callPackage ./lld {
|
|
||||||
inherit llvm_meta;
|
|
||||||
};
|
|
||||||
|
|
||||||
lldb = callPackage ../common/lldb.nix {
|
|
||||||
src = fetch "lldb" "1vlyg015dyng43xqb8cg2l6r9ix8klibxsajazbfnckdnh54hwxj";
|
|
||||||
patches = [
|
|
||||||
./lldb/procfs.patch
|
|
||||||
./lldb/gnu-install-dirs.patch
|
|
||||||
];
|
|
||||||
inherit llvm_meta;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Below, is the LLVM bootstrapping logic. It handles building a
|
|
||||||
# fully LLVM toolchain from scratch. No GCC toolchain should be
|
|
||||||
# pulled in. As a consequence, it is very quick to build different
|
|
||||||
# targets provided by LLVM and we can also build for what GCC
|
|
||||||
# doesn’t support like LLVM. Probably we should move to some other
|
|
||||||
# file.
|
|
||||||
|
|
||||||
bintools-unwrapped = callPackage ../common/bintools.nix { };
|
|
||||||
|
|
||||||
bintoolsNoLibc = wrapBintoolsWith {
|
|
||||||
bintools = tools.bintools-unwrapped;
|
|
||||||
libc = preLibcCrossHeaders;
|
|
||||||
};
|
|
||||||
|
|
||||||
bintools = wrapBintoolsWith {
|
|
||||||
bintools = tools.bintools-unwrapped;
|
|
||||||
};
|
|
||||||
|
|
||||||
clangUseLLVM = wrapCCWith rec {
|
|
||||||
cc = tools.clang-unwrapped;
|
|
||||||
libcxx = targetLlvmLibraries.libcxx;
|
|
||||||
bintools = bintools';
|
|
||||||
extraPackages = [
|
|
||||||
libcxx.cxxabi
|
|
||||||
targetLlvmLibraries.compiler-rt
|
|
||||||
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
|
|
||||||
targetLlvmLibraries.libunwind
|
|
||||||
];
|
|
||||||
extraBuildCommands = ''
|
|
||||||
echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags
|
|
||||||
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
|
||||||
'' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
|
|
||||||
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
|
|
||||||
'' + lib.optionalString (!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false) ''
|
|
||||||
echo "-lunwind" >> $out/nix-support/cc-ldflags
|
|
||||||
'' + lib.optionalString stdenv.targetPlatform.isWasm ''
|
|
||||||
echo "-fno-exceptions" >> $out/nix-support/cc-cflags
|
|
||||||
'' + mkExtraBuildCommands cc;
|
|
||||||
};
|
|
||||||
|
|
||||||
clangNoLibcxx = wrapCCWith rec {
|
|
||||||
cc = tools.clang-unwrapped;
|
|
||||||
libcxx = null;
|
|
||||||
bintools = bintools';
|
|
||||||
extraPackages = [
|
|
||||||
targetLlvmLibraries.compiler-rt
|
|
||||||
];
|
|
||||||
extraBuildCommands = ''
|
|
||||||
echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
|
|
||||||
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
|
||||||
echo "-nostdlib++" >> $out/nix-support/cc-cflags
|
|
||||||
'' + mkExtraBuildCommands cc;
|
|
||||||
};
|
|
||||||
|
|
||||||
clangNoLibc = wrapCCWith rec {
|
|
||||||
cc = tools.clang-unwrapped;
|
|
||||||
libcxx = null;
|
|
||||||
bintools = bintoolsNoLibc';
|
|
||||||
extraPackages = [
|
|
||||||
targetLlvmLibraries.compiler-rt
|
|
||||||
];
|
|
||||||
extraBuildCommands = ''
|
|
||||||
echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
|
|
||||||
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
|
||||||
'' + mkExtraBuildCommands cc;
|
|
||||||
};
|
|
||||||
|
|
||||||
clangNoCompilerRt = wrapCCWith rec {
|
|
||||||
cc = tools.clang-unwrapped;
|
|
||||||
libcxx = null;
|
|
||||||
bintools = bintoolsNoLibc';
|
|
||||||
extraPackages = [ ];
|
|
||||||
extraBuildCommands = ''
|
|
||||||
echo "-nostartfiles" >> $out/nix-support/cc-cflags
|
|
||||||
'' + mkExtraBuildCommands0 cc;
|
|
||||||
};
|
|
||||||
|
|
||||||
clangNoCompilerRtWithLibc = wrapCCWith rec {
|
|
||||||
cc = tools.clang-unwrapped;
|
|
||||||
libcxx = null;
|
|
||||||
bintools = bintools';
|
|
||||||
extraPackages = [ ];
|
|
||||||
extraBuildCommands = mkExtraBuildCommands0 cc;
|
|
||||||
};
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
libraries = lib.makeExtensible (libraries: let
|
|
||||||
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
|
|
||||||
in {
|
|
||||||
|
|
||||||
compiler-rt-libc = callPackage ./compiler-rt {
|
|
||||||
inherit llvm_meta;
|
|
||||||
stdenv = if (stdenv.hostPlatform.useLLVM or false) || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) || (stdenv.hostPlatform.isRiscV && stdenv.hostPlatform.is32bit)
|
|
||||||
then overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc
|
|
||||||
else stdenv;
|
|
||||||
};
|
|
||||||
|
|
||||||
compiler-rt-no-libc = callPackage ./compiler-rt {
|
|
||||||
inherit llvm_meta;
|
|
||||||
stdenv = if (stdenv.hostPlatform.useLLVM or false) || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)
|
|
||||||
then overrideCC stdenv buildLlvmTools.clangNoCompilerRt
|
|
||||||
else stdenv;
|
|
||||||
};
|
|
||||||
|
|
||||||
# N.B. condition is safe because without useLLVM both are the same.
|
|
||||||
compiler-rt = if stdenv.hostPlatform.isAndroid || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) || (stdenv.hostPlatform.libc == "newlib")
|
|
||||||
then libraries.compiler-rt-libc
|
|
||||||
else libraries.compiler-rt-no-libc;
|
|
||||||
|
|
||||||
stdenv = overrideCC stdenv buildLlvmTools.clang;
|
|
||||||
|
|
||||||
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
|
|
||||||
|
|
||||||
libcxx = callPackage ./libcxx {
|
|
||||||
inherit llvm_meta;
|
|
||||||
stdenv = if (stdenv.hostPlatform.useLLVM or false) || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)
|
|
||||||
then overrideCC stdenv buildLlvmTools.clangNoLibcxx
|
|
||||||
else stdenv;
|
|
||||||
};
|
|
||||||
|
|
||||||
libcxxabi = callPackage ./libcxxabi {
|
|
||||||
inherit llvm_meta;
|
|
||||||
stdenv = if (stdenv.hostPlatform.useLLVM or false) || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)
|
|
||||||
then overrideCC stdenv buildLlvmTools.clangNoLibcxx
|
|
||||||
else stdenv;
|
|
||||||
};
|
|
||||||
|
|
||||||
libunwind = callPackage ./libunwind {
|
|
||||||
inherit llvm_meta;
|
|
||||||
stdenv = if (stdenv.hostPlatform.useLLVM or false) || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)
|
|
||||||
then overrideCC stdenv buildLlvmTools.clangNoLibcxx
|
|
||||||
else stdenv;
|
|
||||||
};
|
|
||||||
|
|
||||||
openmp = callPackage ./openmp {
|
|
||||||
inherit llvm_meta targetLlvm;
|
|
||||||
};
|
|
||||||
});
|
|
||||||
noExtend = extensible: builtins.removeAttrs extensible [ "extend" ];
|
|
||||||
|
|
||||||
in { inherit tools libraries release_version; } // (noExtend libraries) // (noExtend tools)
|
|
|
@ -1,363 +0,0 @@
|
||||||
{ lib, stdenv, llvm_meta
|
|
||||||
, pkgsBuildBuild
|
|
||||||
, fetch
|
|
||||||
, fetchpatch
|
|
||||||
, cmake
|
|
||||||
, python3
|
|
||||||
, libffi
|
|
||||||
, enableGoldPlugin ? false
|
|
||||||
, libbfd
|
|
||||||
, libpfm
|
|
||||||
, libxml2
|
|
||||||
, ncurses
|
|
||||||
, version
|
|
||||||
, release_version
|
|
||||||
, zlib
|
|
||||||
, buildLlvmTools
|
|
||||||
, debugVersion ? false
|
|
||||||
, doCheck ? stdenv.isLinux && (!stdenv.isx86_32) && (!stdenv.hostPlatform.isMusl) && (!stdenv.hostPlatform.isRiscV)
|
|
||||||
&& (stdenv.hostPlatform == stdenv.buildPlatform)
|
|
||||||
, enableManpages ? false
|
|
||||||
, enableSharedLibraries ? !stdenv.hostPlatform.isStatic
|
|
||||||
# broken for Ampere eMAG 8180 (c2.large.arm on Packet) #56245
|
|
||||||
# broken for the armv7l builder
|
|
||||||
, enablePFM ? stdenv.isLinux && !stdenv.hostPlatform.isAarch
|
|
||||||
, enablePolly ? false # TODO should be on by default
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (lib) optional optionals optionalString;
|
|
||||||
|
|
||||||
# Used when creating a version-suffixed symlink of libLLVM.dylib
|
|
||||||
shortVersion = with lib;
|
|
||||||
concatStringsSep "." (take 1 (splitString "." release_version));
|
|
||||||
|
|
||||||
# Ordinarily we would just the `doCheck` and `checkDeps` functionality
|
|
||||||
# `mkDerivation` gives us to manage our test dependencies (instead of breaking
|
|
||||||
# out `doCheck` as a package level attribute).
|
|
||||||
#
|
|
||||||
# Unfortunately `lit` does not forward `$PYTHONPATH` to children processes, in
|
|
||||||
# particular the children it uses to do feature detection.
|
|
||||||
#
|
|
||||||
# This means that python deps we add to `checkDeps` (which the python
|
|
||||||
# interpreter is made aware of via `$PYTHONPATH` – populated by the python
|
|
||||||
# setup hook) are not picked up by `lit` which causes it to skip tests.
|
|
||||||
#
|
|
||||||
# Adding `python3.withPackages (ps: [ ... ])` to `checkDeps` also doesn't work
|
|
||||||
# because this package is shadowed in `$PATH` by the regular `python3`
|
|
||||||
# package.
|
|
||||||
#
|
|
||||||
# So, we "manually" assemble one python derivation for the package to depend
|
|
||||||
# on, taking into account whether checks are enabled or not:
|
|
||||||
python = if doCheck then
|
|
||||||
let
|
|
||||||
checkDeps = ps: with ps; [ psutil ];
|
|
||||||
in python3.withPackages checkDeps
|
|
||||||
else python3;
|
|
||||||
|
|
||||||
in stdenv.mkDerivation (rec {
|
|
||||||
pname = "llvm";
|
|
||||||
inherit version;
|
|
||||||
|
|
||||||
src = fetch pname "199yq3a214avcbi4kk2q0ajriifkvsr0l2dkx3a666m033ihi1ff";
|
|
||||||
polly_src = fetch "polly" "031r23ijhx7v93a5n33m2nc0x9xyqmx0d8xg80z7q971p6qd63sq";
|
|
||||||
|
|
||||||
unpackPhase = ''
|
|
||||||
unpackFile $src
|
|
||||||
mv llvm-${release_version}* llvm
|
|
||||||
sourceRoot=$PWD/llvm
|
|
||||||
'' + optionalString enablePolly ''
|
|
||||||
unpackFile $polly_src
|
|
||||||
mv polly-* $sourceRoot/tools/polly
|
|
||||||
'';
|
|
||||||
|
|
||||||
outputs = [ "out" "lib" "dev" "python" ];
|
|
||||||
|
|
||||||
nativeBuildInputs = [ cmake python ]
|
|
||||||
++ optionals enableManpages [ python3.pkgs.sphinx python3.pkgs.recommonmark ];
|
|
||||||
|
|
||||||
buildInputs = [ libxml2 libffi ]
|
|
||||||
++ optional enablePFM libpfm; # exegesis
|
|
||||||
|
|
||||||
propagatedBuildInputs = [ ncurses zlib ];
|
|
||||||
|
|
||||||
patches = [
|
|
||||||
# When cross-compiling we configure llvm-config-native with an approximation
|
|
||||||
# of the flags used for the normal LLVM build. To avoid the need for building
|
|
||||||
# a native libLLVM.so (which would fail) we force llvm-config to be linked
|
|
||||||
# statically against the necessary LLVM components always.
|
|
||||||
../../llvm-config-link-static.patch
|
|
||||||
|
|
||||||
./gnu-install-dirs.patch
|
|
||||||
# On older CPUs (e.g. Hydra/wendy) we'd be getting an error in this test.
|
|
||||||
(fetchpatch {
|
|
||||||
name = "uops-CMOV16rm-noreg.diff";
|
|
||||||
url = "https://github.com/llvm/llvm-project/commit/9e9f991ac033.diff";
|
|
||||||
sha256 = "sha256:12s8vr6ibri8b48h2z38f3afhwam10arfiqfy4yg37bmc054p5hi";
|
|
||||||
stripLen = 1;
|
|
||||||
})
|
|
||||||
# gcc-11 compat upstream patch
|
|
||||||
(fetchpatch {
|
|
||||||
url = "https://github.com/llvm/llvm-project/commit/b498303066a63a203d24f739b2d2e0e56dca70d1.patch";
|
|
||||||
sha256 = "sha256:0nh123kld0dgz2h941lng331dkj3wbm5lfxm375k1f569gv83hlk";
|
|
||||||
stripLen = 1;
|
|
||||||
})
|
|
||||||
|
|
||||||
# Fix invalid std::string(nullptr) for GCC 12
|
|
||||||
(fetchpatch {
|
|
||||||
name = "nvptx-gcc-12.patch";
|
|
||||||
url = "https://github.com/llvm/llvm-project/commit/99e64623ec9b31def9375753491cc6093c831809.patch";
|
|
||||||
sha256 = "0zjfjgavqzi2ypqwqnlvy6flyvdz8hi1anwv0ybwnm2zqixg7za3";
|
|
||||||
stripLen = 1;
|
|
||||||
})
|
|
||||||
(fetchpatch {
|
|
||||||
name = "dfaemitter-gcc-12.patch";
|
|
||||||
url = "https://github.com/llvm/llvm-project/commit/0841916e87a39e3c223c986e8da31e4a9a1432e3.patch";
|
|
||||||
sha256 = "1kckghvsngs51mqm82asy0s9vr19h8aqbw43a0w44mccqw6bzrwf";
|
|
||||||
stripLen = 1;
|
|
||||||
})
|
|
||||||
|
|
||||||
# Fix musl build.
|
|
||||||
(fetchpatch {
|
|
||||||
url = "https://github.com/llvm/llvm-project/commit/5cd554303ead0f8891eee3cd6d25cb07f5a7bf67.patch";
|
|
||||||
relative = "llvm";
|
|
||||||
hash = "sha256-XPbvNJ45SzjMGlNUgt/IgEvM2dHQpDOe6woUJY+nUYA=";
|
|
||||||
})
|
|
||||||
|
|
||||||
# Backport gcc-13 fixes with missing includes.
|
|
||||||
(fetchpatch {
|
|
||||||
name = "signals-gcc-13.patch";
|
|
||||||
url = "https://github.com/llvm/llvm-project/commit/ff1681ddb303223973653f7f5f3f3435b48a1983.patch";
|
|
||||||
hash = "sha256-CXwYxQezTq5vdmc8Yn88BUAEly6YZ5VEIA6X3y5NNOs=";
|
|
||||||
stripLen = 1;
|
|
||||||
})
|
|
||||||
(fetchpatch {
|
|
||||||
name = "base64-gcc-13.patch";
|
|
||||||
url = "https://github.com/llvm/llvm-project/commit/5e9be93566f39ee6cecd579401e453eccfbe81e5.patch";
|
|
||||||
hash = "sha256-PAwrVrvffPd7tphpwCkYiz+67szPRzRB2TXBvKfzQ7U=";
|
|
||||||
stripLen = 1;
|
|
||||||
})
|
|
||||||
] ++ lib.optional enablePolly ./gnu-install-dirs-polly.patch;
|
|
||||||
|
|
||||||
postPatch = optionalString stdenv.isDarwin ''
|
|
||||||
substituteInPlace cmake/modules/AddLLVM.cmake \
|
|
||||||
--replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir)" \
|
|
||||||
--replace 'set(_install_rpath "@loader_path/../''${CMAKE_INSTALL_LIBDIR}''${LLVM_LIBDIR_SUFFIX}" ''${extra_libdir})' ""
|
|
||||||
'' + ''
|
|
||||||
# FileSystem permissions tests fail with various special bits
|
|
||||||
substituteInPlace unittests/Support/CMakeLists.txt \
|
|
||||||
--replace "Path.cpp" ""
|
|
||||||
rm unittests/Support/Path.cpp
|
|
||||||
'' + optionalString stdenv.hostPlatform.isMusl ''
|
|
||||||
patch -p1 -i ${../../TLI-musl.patch}
|
|
||||||
substituteInPlace unittests/Support/CMakeLists.txt \
|
|
||||||
--replace "add_subdirectory(DynamicLibrary)" ""
|
|
||||||
rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
|
|
||||||
# valgrind unhappy with musl or glibc, but fails w/musl only
|
|
||||||
rm test/CodeGen/AArch64/wineh4.mir
|
|
||||||
'' + optionalString stdenv.hostPlatform.isAarch32 ''
|
|
||||||
# skip failing X86 test cases on 32-bit ARM
|
|
||||||
rm test/DebugInfo/X86/convert-debugloc.ll
|
|
||||||
rm test/DebugInfo/X86/convert-inlined.ll
|
|
||||||
rm test/DebugInfo/X86/convert-linked.ll
|
|
||||||
rm test/tools/dsymutil/X86/op-convert.test
|
|
||||||
rm test/tools/gold/X86/split-dwarf.ll
|
|
||||||
rm test/tools/llvm-readobj/ELF/dependent-libraries.test
|
|
||||||
'' + optionalString (stdenv.hostPlatform.system == "armv6l-linux") ''
|
|
||||||
# Seems to require certain floating point hardware (NEON?)
|
|
||||||
rm test/ExecutionEngine/frem.ll
|
|
||||||
'' + ''
|
|
||||||
patchShebangs test/BugPoint/compile-custom.ll.py
|
|
||||||
'' + ''
|
|
||||||
# Tweak tests to ignore namespace part of type to support
|
|
||||||
# gcc-12: https://gcc.gnu.org/PR103598.
|
|
||||||
# The change below mangles strings like:
|
|
||||||
# CHECK-NEXT: Starting llvm::Function pass manager run.
|
|
||||||
# to:
|
|
||||||
# CHECK-NEXT: Starting {{.*}}Function pass manager run.
|
|
||||||
for f in \
|
|
||||||
test/Other/new-pass-manager.ll \
|
|
||||||
test/Other/new-pm-defaults.ll \
|
|
||||||
test/Other/new-pm-lto-defaults.ll \
|
|
||||||
test/Other/new-pm-thinlto-defaults.ll \
|
|
||||||
test/Other/pass-pipeline-parsing.ll \
|
|
||||||
test/Transforms/Inline/cgscc-incremental-invalidate.ll \
|
|
||||||
test/Transforms/Inline/clear-analyses.ll \
|
|
||||||
test/Transforms/LoopUnroll/unroll-loop-invalidation.ll \
|
|
||||||
test/Transforms/SCCP/ipsccp-preserve-analysis.ll \
|
|
||||||
test/Transforms/SCCP/preserve-analysis.ll \
|
|
||||||
test/Transforms/SROA/dead-inst.ll \
|
|
||||||
test/tools/gold/X86/new-pm.ll \
|
|
||||||
; do
|
|
||||||
echo "PATCH: $f"
|
|
||||||
substituteInPlace $f \
|
|
||||||
--replace 'Starting llvm::' 'Starting {{.*}}' \
|
|
||||||
--replace 'Finished llvm::' 'Finished {{.*}}'
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
|
|
||||||
preConfigure = ''
|
|
||||||
# Workaround for configure flags that need to have spaces
|
|
||||||
cmakeFlagsArray+=(
|
|
||||||
-DLLVM_LIT_ARGS='-svj''${NIX_BUILD_CORES} --no-progress-bar'
|
|
||||||
)
|
|
||||||
'';
|
|
||||||
|
|
||||||
# hacky fix: created binaries need to be run before installation
|
|
||||||
preBuild = ''
|
|
||||||
mkdir -p $out/
|
|
||||||
ln -sv $PWD/lib $out
|
|
||||||
'';
|
|
||||||
|
|
||||||
# E.g. mesa.drivers use the build-id as a cache key (see #93946):
|
|
||||||
LDFLAGS = optionalString (enableSharedLibraries && !stdenv.isDarwin) "-Wl,--build-id=sha1";
|
|
||||||
|
|
||||||
cmakeBuildType = if debugVersion then "Debug" else "Release";
|
|
||||||
|
|
||||||
cmakeFlags = with stdenv; let
|
|
||||||
# These flags influence llvm-config's BuildVariables.inc in addition to the
|
|
||||||
# general build. We need to make sure these are also passed via
|
|
||||||
# CROSS_TOOLCHAIN_FLAGS_NATIVE when cross-compiling or llvm-config-native
|
|
||||||
# will return different results from the cross llvm-config.
|
|
||||||
#
|
|
||||||
# Some flags don't need to be repassed because LLVM already does so (like
|
|
||||||
# CMAKE_BUILD_TYPE), others are irrelevant to the result.
|
|
||||||
flagsForLlvmConfig = [
|
|
||||||
"-DLLVM_INSTALL_CMAKE_DIR=${placeholder "dev"}/lib/cmake/llvm/"
|
|
||||||
"-DLLVM_ENABLE_RTTI=ON"
|
|
||||||
] ++ optionals enableSharedLibraries [
|
|
||||||
"-DLLVM_LINK_LLVM_DYLIB=ON"
|
|
||||||
];
|
|
||||||
in flagsForLlvmConfig ++ [
|
|
||||||
"-DLLVM_INSTALL_UTILS=ON" # Needed by rustc
|
|
||||||
"-DLLVM_BUILD_TESTS=${if doCheck then "ON" else "OFF"}"
|
|
||||||
"-DLLVM_ENABLE_FFI=ON"
|
|
||||||
"-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
|
|
||||||
"-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}"
|
|
||||||
"-DLLVM_ENABLE_DUMP=ON"
|
|
||||||
] ++ optionals stdenv.hostPlatform.isStatic [
|
|
||||||
# Disables building of shared libs, -fPIC is still injected by cc-wrapper
|
|
||||||
"-DLLVM_ENABLE_PIC=OFF"
|
|
||||||
"-DLLVM_BUILD_STATIC=ON"
|
|
||||||
# libxml2 needs to be disabled because the LLVM build system ignores its .la
|
|
||||||
# file and doesn't link zlib as well.
|
|
||||||
# https://github.com/ClangBuiltLinux/tc-build/issues/150#issuecomment-845418812
|
|
||||||
"-DLLVM_ENABLE_LIBXML2=OFF"
|
|
||||||
# This is a Shared Library not tied to LLVM_ENABLE_PIC
|
|
||||||
"-DLLVM_TOOL_REMARKS_SHLIB_BUILD=OFF"
|
|
||||||
] ++ optionals enableManpages [
|
|
||||||
"-DLLVM_BUILD_DOCS=ON"
|
|
||||||
"-DLLVM_ENABLE_SPHINX=ON"
|
|
||||||
"-DSPHINX_OUTPUT_MAN=ON"
|
|
||||||
"-DSPHINX_OUTPUT_HTML=OFF"
|
|
||||||
"-DSPHINX_WARNINGS_AS_ERRORS=OFF"
|
|
||||||
] ++ optionals (enableGoldPlugin) [
|
|
||||||
"-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
|
|
||||||
] ++ optionals isDarwin [
|
|
||||||
"-DLLVM_ENABLE_LIBCXX=ON"
|
|
||||||
"-DCAN_TARGET_i386=false"
|
|
||||||
] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
|
||||||
"-DCMAKE_CROSSCOMPILING=True"
|
|
||||||
"-DLLVM_TABLEGEN=${buildLlvmTools.llvm}/bin/llvm-tblgen"
|
|
||||||
(
|
|
||||||
let
|
|
||||||
nativeCC = pkgsBuildBuild.targetPackages.stdenv.cc;
|
|
||||||
nativeBintools = nativeCC.bintools.bintools;
|
|
||||||
nativeToolchainFlags = [
|
|
||||||
"-DCMAKE_C_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}cc"
|
|
||||||
"-DCMAKE_CXX_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}c++"
|
|
||||||
"-DCMAKE_AR=${nativeBintools}/bin/${nativeBintools.targetPrefix}ar"
|
|
||||||
"-DCMAKE_STRIP=${nativeBintools}/bin/${nativeBintools.targetPrefix}strip"
|
|
||||||
"-DCMAKE_RANLIB=${nativeBintools}/bin/${nativeBintools.targetPrefix}ranlib"
|
|
||||||
];
|
|
||||||
# We need to repass the custom GNUInstallDirs values, otherwise CMake
|
|
||||||
# will choose them for us, leading to wrong results in llvm-config-native
|
|
||||||
nativeInstallFlags = [
|
|
||||||
"-DCMAKE_INSTALL_PREFIX=${placeholder "out"}"
|
|
||||||
"-DCMAKE_INSTALL_BINDIR=${placeholder "out"}/bin"
|
|
||||||
"-DCMAKE_INSTALL_INCLUDEDIR=${placeholder "dev"}/include"
|
|
||||||
"-DCMAKE_INSTALL_LIBDIR=${placeholder "lib"}/lib"
|
|
||||||
"-DCMAKE_INSTALL_LIBEXECDIR=${placeholder "lib"}/libexec"
|
|
||||||
];
|
|
||||||
in "-DCROSS_TOOLCHAIN_FLAGS_NATIVE:list="
|
|
||||||
+ lib.concatStringsSep ";" (lib.concatLists [
|
|
||||||
flagsForLlvmConfig
|
|
||||||
nativeToolchainFlags
|
|
||||||
nativeInstallFlags
|
|
||||||
])
|
|
||||||
)
|
|
||||||
];
|
|
||||||
|
|
||||||
postBuild = ''
|
|
||||||
rm -fR $out
|
|
||||||
'';
|
|
||||||
|
|
||||||
preCheck = ''
|
|
||||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}$PWD/lib
|
|
||||||
'';
|
|
||||||
|
|
||||||
postInstall = ''
|
|
||||||
mkdir -p $python/share
|
|
||||||
mv $out/share/opt-viewer $python/share/opt-viewer
|
|
||||||
moveToOutput "bin/llvm-config*" "$dev"
|
|
||||||
substituteInPlace "$dev/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
|
|
||||||
--replace "\''${_IMPORT_PREFIX}/lib/lib" "$lib/lib/lib" \
|
|
||||||
--replace "$out/bin/llvm-config" "$dev/bin/llvm-config"
|
|
||||||
substituteInPlace "$dev/lib/cmake/llvm/LLVMConfig.cmake" \
|
|
||||||
--replace 'set(LLVM_BINARY_DIR "''${LLVM_INSTALL_PREFIX}")' 'set(LLVM_BINARY_DIR "''${LLVM_INSTALL_PREFIX}'"$lib"'")'
|
|
||||||
''
|
|
||||||
+ optionalString (stdenv.isDarwin && enableSharedLibraries) ''
|
|
||||||
ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib
|
|
||||||
ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib
|
|
||||||
''
|
|
||||||
+ optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
|
|
||||||
cp NATIVE/bin/llvm-config $dev/bin/llvm-config-native
|
|
||||||
'';
|
|
||||||
|
|
||||||
inherit doCheck;
|
|
||||||
|
|
||||||
checkTarget = "check-all";
|
|
||||||
|
|
||||||
requiredSystemFeatures = [ "big-parallel" ];
|
|
||||||
meta = llvm_meta // {
|
|
||||||
homepage = "https://llvm.org/";
|
|
||||||
description = "A collection of modular and reusable compiler and toolchain technologies";
|
|
||||||
longDescription = ''
|
|
||||||
The LLVM Project is a collection of modular and reusable compiler and
|
|
||||||
toolchain technologies. Despite its name, LLVM has little to do with
|
|
||||||
traditional virtual machines. The name "LLVM" itself is not an acronym; it
|
|
||||||
is the full name of the project.
|
|
||||||
LLVM began as a research project at the University of Illinois, with the
|
|
||||||
goal of providing a modern, SSA-based compilation strategy capable of
|
|
||||||
supporting both static and dynamic compilation of arbitrary programming
|
|
||||||
languages. Since then, LLVM has grown to be an umbrella project consisting
|
|
||||||
of a number of subprojects, many of which are being used in production by
|
|
||||||
a wide variety of commercial and open source projects as well as being
|
|
||||||
widely used in academic research. Code in the LLVM project is licensed
|
|
||||||
under the "Apache 2.0 License with LLVM exceptions".
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
} // lib.optionalAttrs enableManpages {
|
|
||||||
pname = "llvm-manpages";
|
|
||||||
|
|
||||||
buildPhase = ''
|
|
||||||
make docs-llvm-man
|
|
||||||
'';
|
|
||||||
|
|
||||||
propagatedBuildInputs = [];
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
make -C docs install
|
|
||||||
'';
|
|
||||||
|
|
||||||
postPatch = null;
|
|
||||||
postInstall = null;
|
|
||||||
|
|
||||||
outputs = [ "out" ];
|
|
||||||
|
|
||||||
doCheck = false;
|
|
||||||
|
|
||||||
meta = llvm_meta // {
|
|
||||||
description = "man pages for LLVM ${version}";
|
|
||||||
};
|
|
||||||
})
|
|
|
@ -1,106 +0,0 @@
|
||||||
diff --git a/tools/polly/CMakeLists.txt b/tools/polly/CMakeLists.txt
|
|
||||||
index 9939097f743e..8cc538da912a 100644
|
|
||||||
--- a/tools/polly/CMakeLists.txt
|
|
||||||
+++ b/tools/polly/CMakeLists.txt
|
|
||||||
@@ -2,7 +2,11 @@
|
|
||||||
if (NOT DEFINED LLVM_MAIN_SRC_DIR)
|
|
||||||
project(Polly)
|
|
||||||
cmake_minimum_required(VERSION 3.4.3)
|
|
||||||
+endif()
|
|
||||||
+
|
|
||||||
+include(GNUInstallDirs)
|
|
||||||
|
|
||||||
+if (NOT DEFINED LLVM_MAIN_SRC_DIR)
|
|
||||||
# Where is LLVM installed?
|
|
||||||
find_package(LLVM CONFIG REQUIRED)
|
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LLVM_CMAKE_DIR})
|
|
||||||
@@ -145,14 +149,14 @@ include_directories(
|
|
||||||
|
|
||||||
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
|
|
||||||
install(DIRECTORY include/
|
|
||||||
- DESTINATION include
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
|
||||||
FILES_MATCHING
|
|
||||||
PATTERN "*.h"
|
|
||||||
PATTERN ".svn" EXCLUDE
|
|
||||||
)
|
|
||||||
|
|
||||||
install(DIRECTORY ${POLLY_BINARY_DIR}/include/
|
|
||||||
- DESTINATION include
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
|
||||||
FILES_MATCHING
|
|
||||||
PATTERN "*.h"
|
|
||||||
PATTERN "CMakeFiles" EXCLUDE
|
|
||||||
diff --git a/tools/polly/cmake/CMakeLists.txt b/tools/polly/cmake/CMakeLists.txt
|
|
||||||
index 211f95512717..f9e04a4844b6 100644
|
|
||||||
--- a/tools/polly/cmake/CMakeLists.txt
|
|
||||||
+++ b/tools/polly/cmake/CMakeLists.txt
|
|
||||||
@@ -79,18 +79,18 @@ file(GENERATE
|
|
||||||
|
|
||||||
# Generate PollyConfig.cmake for the install tree.
|
|
||||||
unset(POLLY_EXPORTS)
|
|
||||||
-set(POLLY_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
|
|
||||||
+set(POLLY_INSTALL_PREFIX "")
|
|
||||||
set(POLLY_CONFIG_LLVM_CMAKE_DIR "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
|
|
||||||
-set(POLLY_CONFIG_CMAKE_DIR "${POLLY_INSTALL_PREFIX}/${POLLY_INSTALL_PACKAGE_DIR}")
|
|
||||||
-set(POLLY_CONFIG_LIBRARY_DIRS "${POLLY_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}")
|
|
||||||
+set(POLLY_CONFIG_CMAKE_DIR "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_PREFIX}/${POLLY_INSTALL_PACKAGE_DIR}")
|
|
||||||
+set(POLLY_CONFIG_LIBRARY_DIRS "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_FULL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
|
|
||||||
if (POLLY_BUNDLED_ISL)
|
|
||||||
set(POLLY_CONFIG_INCLUDE_DIRS
|
|
||||||
- "${POLLY_INSTALL_PREFIX}/include"
|
|
||||||
- "${POLLY_INSTALL_PREFIX}/include/polly"
|
|
||||||
+ "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_FULL_LIBDIR}"
|
|
||||||
+ "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_FULL_LIBDIR}/polly"
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
set(POLLY_CONFIG_INCLUDE_DIRS
|
|
||||||
- "${POLLY_INSTALL_PREFIX}/include"
|
|
||||||
+ "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_FULL_INCLUDEDIR}"
|
|
||||||
${ISL_INCLUDE_DIRS}
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
@@ -100,12 +100,12 @@ endif()
|
|
||||||
foreach(tgt IN LISTS POLLY_CONFIG_EXPORTED_TARGETS)
|
|
||||||
get_target_property(tgt_type ${tgt} TYPE)
|
|
||||||
if (tgt_type STREQUAL "EXECUTABLE")
|
|
||||||
- set(tgt_prefix "bin/")
|
|
||||||
+ set(tgt_prefix "${CMAKE_INSTALL_BINDIR}/")
|
|
||||||
else()
|
|
||||||
- set(tgt_prefix "lib/")
|
|
||||||
+ set(tgt_prefix "${CMAKE_INSTALL_LIBDIR}/")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
- set(tgt_path "${CMAKE_INSTALL_PREFIX}/${tgt_prefix}$<TARGET_FILE_NAME:${tgt}>")
|
|
||||||
+ set(tgt_path "${tgt_prefix}$<TARGET_FILE_NAME:${tgt}>")
|
|
||||||
file(RELATIVE_PATH tgt_path ${POLLY_CONFIG_CMAKE_DIR} ${tgt_path})
|
|
||||||
|
|
||||||
if (NOT tgt_type STREQUAL "INTERFACE_LIBRARY")
|
|
||||||
diff --git a/tools/polly/cmake/polly_macros.cmake b/tools/polly/cmake/polly_macros.cmake
|
|
||||||
index 86de6f10686e..91f30891ccbe 100644
|
|
||||||
--- a/tools/polly/cmake/polly_macros.cmake
|
|
||||||
+++ b/tools/polly/cmake/polly_macros.cmake
|
|
||||||
@@ -44,8 +44,8 @@ macro(add_polly_library name)
|
|
||||||
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "LLVMPolly")
|
|
||||||
install(TARGETS ${name}
|
|
||||||
EXPORT LLVMExports
|
|
||||||
- LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
|
|
||||||
- ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
|
|
||||||
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}
|
|
||||||
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX})
|
|
||||||
endif()
|
|
||||||
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
|
|
||||||
endmacro(add_polly_library)
|
|
||||||
diff --git a/tools/polly/lib/External/CMakeLists.txt b/tools/polly/lib/External/CMakeLists.txt
|
|
||||||
index 1039079cb49c..28b499ae1e9e 100644
|
|
||||||
--- a/tools/polly/lib/External/CMakeLists.txt
|
|
||||||
+++ b/tools/polly/lib/External/CMakeLists.txt
|
|
||||||
@@ -275,7 +275,7 @@ if (POLLY_BUNDLED_ISL)
|
|
||||||
install(DIRECTORY
|
|
||||||
${ISL_SOURCE_DIR}/include/
|
|
||||||
${ISL_BINARY_DIR}/include/
|
|
||||||
- DESTINATION include/polly
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/polly
|
|
||||||
FILES_MATCHING
|
|
||||||
PATTERN "*.h"
|
|
||||||
PATTERN "CMakeFiles" EXCLUDE
|
|
|
@ -1,417 +0,0 @@
|
||||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
||||||
index 247ad36d3845..815e2c4ba955 100644
|
|
||||||
--- a/CMakeLists.txt
|
|
||||||
+++ b/CMakeLists.txt
|
|
||||||
@@ -269,15 +269,21 @@ if (CMAKE_BUILD_TYPE AND
|
|
||||||
message(FATAL_ERROR "Invalid value for CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
+include(GNUInstallDirs)
|
|
||||||
+
|
|
||||||
set(LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" )
|
|
||||||
|
|
||||||
-set(LLVM_TOOLS_INSTALL_DIR "bin" CACHE STRING "Path for binary subdirectory (defaults to 'bin')")
|
|
||||||
+set(LLVM_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING
|
|
||||||
+ "Path for binary subdirectory (defaults to 'bin')")
|
|
||||||
mark_as_advanced(LLVM_TOOLS_INSTALL_DIR)
|
|
||||||
|
|
||||||
set(LLVM_UTILS_INSTALL_DIR "${LLVM_TOOLS_INSTALL_DIR}" CACHE STRING
|
|
||||||
"Path to install LLVM utilities (enabled by LLVM_INSTALL_UTILS=ON) (defaults to LLVM_TOOLS_INSTALL_DIR)")
|
|
||||||
mark_as_advanced(LLVM_UTILS_INSTALL_DIR)
|
|
||||||
|
|
||||||
+set(LLVM_INSTALL_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/cmake/llvm" CACHE STRING
|
|
||||||
+ "Path for CMake subdirectory (defaults to lib/cmake/llvm)" )
|
|
||||||
+
|
|
||||||
# They are used as destination of target generators.
|
|
||||||
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
|
|
||||||
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
|
|
||||||
@@ -559,9 +565,9 @@ option (LLVM_ENABLE_SPHINX "Use Sphinx to generate llvm documentation." OFF)
|
|
||||||
option (LLVM_ENABLE_OCAMLDOC "Build OCaml bindings documentation." ON)
|
|
||||||
option (LLVM_ENABLE_BINDINGS "Build bindings." ON)
|
|
||||||
|
|
||||||
-set(LLVM_INSTALL_DOXYGEN_HTML_DIR "share/doc/llvm/doxygen-html"
|
|
||||||
+set(LLVM_INSTALL_DOXYGEN_HTML_DIR "${CMAKE_INSTALL_DOCDIR}/${project}/doxygen-html"
|
|
||||||
CACHE STRING "Doxygen-generated HTML documentation install directory")
|
|
||||||
-set(LLVM_INSTALL_OCAMLDOC_HTML_DIR "share/doc/llvm/ocaml-html"
|
|
||||||
+set(LLVM_INSTALL_OCAMLDOC_HTML_DIR "${CMAKE_INSTALL_DOCDIR}/${project}/ocaml-html"
|
|
||||||
CACHE STRING "OCamldoc-generated HTML documentation install directory")
|
|
||||||
|
|
||||||
option (LLVM_BUILD_EXTERNAL_COMPILER_RT
|
|
||||||
@@ -1107,7 +1113,7 @@ endif()
|
|
||||||
|
|
||||||
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
|
|
||||||
install(DIRECTORY include/llvm include/llvm-c
|
|
||||||
- DESTINATION include
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
|
||||||
COMPONENT llvm-headers
|
|
||||||
FILES_MATCHING
|
|
||||||
PATTERN "*.def"
|
|
||||||
@@ -1119,7 +1125,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
|
|
||||||
)
|
|
||||||
|
|
||||||
install(DIRECTORY ${LLVM_INCLUDE_DIR}/llvm ${LLVM_INCLUDE_DIR}/llvm-c
|
|
||||||
- DESTINATION include
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
|
||||||
COMPONENT llvm-headers
|
|
||||||
FILES_MATCHING
|
|
||||||
PATTERN "*.def"
|
|
||||||
@@ -1134,13 +1140,13 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
|
|
||||||
|
|
||||||
if (LLVM_INSTALL_MODULEMAPS)
|
|
||||||
install(DIRECTORY include/llvm include/llvm-c
|
|
||||||
- DESTINATION include
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
|
||||||
COMPONENT llvm-headers
|
|
||||||
FILES_MATCHING
|
|
||||||
PATTERN "module.modulemap"
|
|
||||||
)
|
|
||||||
install(FILES include/llvm/module.install.modulemap
|
|
||||||
- DESTINATION include/llvm
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/llvm
|
|
||||||
COMPONENT llvm-headers
|
|
||||||
RENAME "module.extern.modulemap"
|
|
||||||
)
|
|
||||||
diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
|
|
||||||
index b74adc11ade9..a5aa258cde30 100644
|
|
||||||
--- a/cmake/modules/AddLLVM.cmake
|
|
||||||
+++ b/cmake/modules/AddLLVM.cmake
|
|
||||||
@@ -766,9 +766,9 @@ macro(add_llvm_library name)
|
|
||||||
|
|
||||||
install(TARGETS ${name}
|
|
||||||
${export_to_llvmexports}
|
|
||||||
- LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT ${name}
|
|
||||||
- ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT ${name}
|
|
||||||
- RUNTIME DESTINATION bin COMPONENT ${name})
|
|
||||||
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX} COMPONENT ${name}
|
|
||||||
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX} COMPONENT ${name}
|
|
||||||
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${name})
|
|
||||||
|
|
||||||
if (NOT LLVM_ENABLE_IDE)
|
|
||||||
add_llvm_install_targets(install-${name}
|
|
||||||
@@ -981,7 +981,7 @@ function(process_llvm_pass_plugins)
|
|
||||||
"set(LLVM_STATIC_EXTENSIONS ${LLVM_STATIC_EXTENSIONS})")
|
|
||||||
install(FILES
|
|
||||||
${llvm_cmake_builddir}/LLVMConfigExtensions.cmake
|
|
||||||
- DESTINATION ${LLVM_INSTALL_PACKAGE_DIR}
|
|
||||||
+ DESTINATION ${LLVM_INSTALL_CMAKE_DIR}
|
|
||||||
COMPONENT cmake-exports)
|
|
||||||
|
|
||||||
set(ExtensionDef "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def")
|
|
||||||
@@ -1201,7 +1201,7 @@ macro(add_llvm_example name)
|
|
||||||
endif()
|
|
||||||
add_llvm_executable(${name} ${ARGN})
|
|
||||||
if( LLVM_BUILD_EXAMPLES )
|
|
||||||
- install(TARGETS ${name} RUNTIME DESTINATION examples)
|
|
||||||
+ install(TARGETS ${name} RUNTIME DESTINATION ${CMAKE_INSTALL_DOCDIR}/examples)
|
|
||||||
endif()
|
|
||||||
set_target_properties(${name} PROPERTIES FOLDER "Examples")
|
|
||||||
endmacro(add_llvm_example name)
|
|
||||||
@@ -1819,7 +1819,7 @@ function(llvm_install_library_symlink name dest type)
|
|
||||||
set(full_name ${CMAKE_${type}_LIBRARY_PREFIX}${name}${CMAKE_${type}_LIBRARY_SUFFIX})
|
|
||||||
set(full_dest ${CMAKE_${type}_LIBRARY_PREFIX}${dest}${CMAKE_${type}_LIBRARY_SUFFIX})
|
|
||||||
|
|
||||||
- set(output_dir lib${LLVM_LIBDIR_SUFFIX})
|
|
||||||
+ set(output_dir ${CMAKE_INSTALL_FULL_LIBDIR}${LLVM_LIBDIR_SUFFIX})
|
|
||||||
if(WIN32 AND "${type}" STREQUAL "SHARED")
|
|
||||||
set(output_dir bin)
|
|
||||||
endif()
|
|
||||||
@@ -1836,7 +1836,7 @@ function(llvm_install_library_symlink name dest type)
|
|
||||||
endif()
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
-function(llvm_install_symlink name dest)
|
|
||||||
+function(llvm_install_symlink name dest output_dir)
|
|
||||||
cmake_parse_arguments(ARG "ALWAYS_GENERATE" "COMPONENT" "" ${ARGN})
|
|
||||||
foreach(path ${CMAKE_MODULE_PATH})
|
|
||||||
if(EXISTS ${path}/LLVMInstallSymlink.cmake)
|
|
||||||
@@ -1859,7 +1859,7 @@ function(llvm_install_symlink name dest)
|
|
||||||
set(full_dest ${dest}${CMAKE_EXECUTABLE_SUFFIX})
|
|
||||||
|
|
||||||
install(SCRIPT ${INSTALL_SYMLINK}
|
|
||||||
- CODE "install_symlink(${full_name} ${full_dest} ${LLVM_TOOLS_INSTALL_DIR})"
|
|
||||||
+ CODE "install_symlink(${full_name} ${full_dest} ${output_dir})"
|
|
||||||
COMPONENT ${component})
|
|
||||||
|
|
||||||
if (NOT LLVM_ENABLE_IDE AND NOT ARG_ALWAYS_GENERATE)
|
|
||||||
@@ -1942,7 +1942,8 @@ function(add_llvm_tool_symlink link_name target)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if ((TOOL_IS_TOOLCHAIN OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY) AND LLVM_BUILD_TOOLS)
|
|
||||||
- llvm_install_symlink(${link_name} ${target})
|
|
||||||
+ GNUInstallDirs_get_absolute_install_dir(output_dir LLVM_TOOLS_INSTALL_DIR)
|
|
||||||
+ llvm_install_symlink(${link_name} ${target} ${output_dir})
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endfunction()
|
|
||||||
@@ -2064,9 +2065,9 @@ function(llvm_setup_rpath name)
|
|
||||||
|
|
||||||
if (APPLE)
|
|
||||||
set(_install_name_dir INSTALL_NAME_DIR "@rpath")
|
|
||||||
- set(_install_rpath "@loader_path/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
|
|
||||||
+ set(_install_rpath "@loader_path/../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
|
|
||||||
elseif(UNIX)
|
|
||||||
- set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
|
|
||||||
+ set(_install_rpath "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
|
|
||||||
if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")
|
|
||||||
set_property(TARGET ${name} APPEND_STRING PROPERTY
|
|
||||||
LINK_FLAGS " -Wl,-z,origin ")
|
|
||||||
diff --git a/cmake/modules/AddOCaml.cmake b/cmake/modules/AddOCaml.cmake
|
|
||||||
index 554046b20edf..4d1ad980641e 100644
|
|
||||||
--- a/cmake/modules/AddOCaml.cmake
|
|
||||||
+++ b/cmake/modules/AddOCaml.cmake
|
|
||||||
@@ -144,9 +144,9 @@ function(add_ocaml_library name)
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
if( APPLE )
|
|
||||||
- set(ocaml_rpath "@executable_path/../../../lib${LLVM_LIBDIR_SUFFIX}")
|
|
||||||
+ set(ocaml_rpath "@executable_path/../../../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
|
|
||||||
elseif( UNIX )
|
|
||||||
- set(ocaml_rpath "\\$ORIGIN/../../../lib${LLVM_LIBDIR_SUFFIX}")
|
|
||||||
+ set(ocaml_rpath "\\$ORIGIN/../../../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
|
|
||||||
endif()
|
|
||||||
list(APPEND ocaml_flags "-ldopt" "-Wl,-rpath,${ocaml_rpath}")
|
|
||||||
|
|
||||||
diff --git a/cmake/modules/AddSphinxTarget.cmake b/cmake/modules/AddSphinxTarget.cmake
|
|
||||||
index b5babb30abcf..190b1222a9f9 100644
|
|
||||||
--- a/cmake/modules/AddSphinxTarget.cmake
|
|
||||||
+++ b/cmake/modules/AddSphinxTarget.cmake
|
|
||||||
@@ -84,7 +84,7 @@ function (add_sphinx_target builder project)
|
|
||||||
endif()
|
|
||||||
elseif (builder STREQUAL html)
|
|
||||||
string(TOUPPER "${project}" project_upper)
|
|
||||||
- set(${project_upper}_INSTALL_SPHINX_HTML_DIR "share/doc/${project}/html"
|
|
||||||
+ set(${project_upper}_INSTALL_SPHINX_HTML_DIR "${CMAKE_INSTALL_DOCDIR}/${project}/html"
|
|
||||||
CACHE STRING "HTML documentation install directory for ${project}")
|
|
||||||
|
|
||||||
# '/.' indicates: copy the contents of the directory directly into
|
|
||||||
diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt
|
|
||||||
index 4b8879f65fe4..f01920bcc60f 100644
|
|
||||||
--- a/cmake/modules/CMakeLists.txt
|
|
||||||
+++ b/cmake/modules/CMakeLists.txt
|
|
||||||
@@ -1,4 +1,4 @@
|
|
||||||
-set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
|
|
||||||
+set(LLVM_INSTALL_PACKAGE_DIR ${LLVM_INSTALL_CMAKE_DIR} CACHE STRING "Path for CMake subdirectory (defaults to 'cmake/llvm')")
|
|
||||||
set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
|
|
||||||
|
|
||||||
# First for users who use an installed LLVM, create the LLVMExports.cmake file.
|
|
||||||
@@ -108,13 +108,13 @@ foreach(p ${_count})
|
|
||||||
set(LLVM_CONFIG_CODE "${LLVM_CONFIG_CODE}
|
|
||||||
get_filename_component(LLVM_INSTALL_PREFIX \"\${LLVM_INSTALL_PREFIX}\" PATH)")
|
|
||||||
endforeach(p)
|
|
||||||
-set(LLVM_CONFIG_INCLUDE_DIRS "\${LLVM_INSTALL_PREFIX}/include")
|
|
||||||
+set(LLVM_CONFIG_INCLUDE_DIRS "\${LLVM_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
|
|
||||||
set(LLVM_CONFIG_INCLUDE_DIR "${LLVM_CONFIG_INCLUDE_DIRS}")
|
|
||||||
set(LLVM_CONFIG_MAIN_INCLUDE_DIR "${LLVM_CONFIG_INCLUDE_DIRS}")
|
|
||||||
-set(LLVM_CONFIG_LIBRARY_DIRS "\${LLVM_INSTALL_PREFIX}/lib\${LLVM_LIBDIR_SUFFIX}")
|
|
||||||
+set(LLVM_CONFIG_LIBRARY_DIRS "\${LLVM_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}\${LLVM_LIBDIR_SUFFIX}")
|
|
||||||
set(LLVM_CONFIG_CMAKE_DIR "\${LLVM_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
|
|
||||||
set(LLVM_CONFIG_BINARY_DIR "\${LLVM_INSTALL_PREFIX}")
|
|
||||||
-set(LLVM_CONFIG_TOOLS_BINARY_DIR "\${LLVM_INSTALL_PREFIX}/bin")
|
|
||||||
+set(LLVM_CONFIG_TOOLS_BINARY_DIR "\${LLVM_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
|
|
||||||
|
|
||||||
# Generate a default location for lit
|
|
||||||
if (LLVM_INSTALL_UTILS AND LLVM_BUILD_UTILS)
|
|
||||||
diff --git a/cmake/modules/LLVMInstallSymlink.cmake b/cmake/modules/LLVMInstallSymlink.cmake
|
|
||||||
index 09fed8085c23..aa79f192abf0 100644
|
|
||||||
--- a/cmake/modules/LLVMInstallSymlink.cmake
|
|
||||||
+++ b/cmake/modules/LLVMInstallSymlink.cmake
|
|
||||||
@@ -10,7 +10,7 @@ function(install_symlink name target outdir)
|
|
||||||
set(LINK_OR_COPY copy)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
- set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}/")
|
|
||||||
+ set(bindir "${DESTDIR}${outdir}/")
|
|
||||||
|
|
||||||
message(STATUS "Creating ${name}")
|
|
||||||
|
|
||||||
diff --git a/docs/CMake.rst b/docs/CMake.rst
|
|
||||||
index 1f908d3e95b1..1315e0aa40e1 100644
|
|
||||||
--- a/docs/CMake.rst
|
|
||||||
+++ b/docs/CMake.rst
|
|
||||||
@@ -196,7 +196,7 @@ CMake manual, or execute ``cmake --help-variable VARIABLE_NAME``.
|
|
||||||
**LLVM_LIBDIR_SUFFIX**:STRING
|
|
||||||
Extra suffix to append to the directory where libraries are to be
|
|
||||||
installed. On a 64-bit architecture, one could use ``-DLLVM_LIBDIR_SUFFIX=64``
|
|
||||||
- to install libraries to ``/usr/lib64``.
|
|
||||||
+ to install libraries to ``/usr/lib64``. See also ``CMAKE_INSTALL_LIBDIR``.
|
|
||||||
|
|
||||||
**CMAKE_C_FLAGS**:STRING
|
|
||||||
Extra flags to use when compiling C source files.
|
|
||||||
@@ -516,8 +516,8 @@ LLVM-specific variables
|
|
||||||
|
|
||||||
**LLVM_INSTALL_DOXYGEN_HTML_DIR**:STRING
|
|
||||||
The path to install Doxygen-generated HTML documentation to. This path can
|
|
||||||
- either be absolute or relative to the CMAKE_INSTALL_PREFIX. Defaults to
|
|
||||||
- `share/doc/llvm/doxygen-html`.
|
|
||||||
+ either be absolute or relative to the ``CMAKE_INSTALL_PREFIX``. Defaults to
|
|
||||||
+ `${CMAKE_INSTALL_DOCDIR}/${project}/doxygen-html`.
|
|
||||||
|
|
||||||
**LLVM_ENABLE_SPHINX**:BOOL
|
|
||||||
If specified, CMake will search for the ``sphinx-build`` executable and will make
|
|
||||||
@@ -548,13 +548,33 @@ LLVM-specific variables
|
|
||||||
|
|
||||||
**LLVM_INSTALL_SPHINX_HTML_DIR**:STRING
|
|
||||||
The path to install Sphinx-generated HTML documentation to. This path can
|
|
||||||
- either be absolute or relative to the CMAKE_INSTALL_PREFIX. Defaults to
|
|
||||||
- `share/doc/llvm/html`.
|
|
||||||
+ either be absolute or relative to the ``CMAKE_INSTALL_PREFIX``. Defaults to
|
|
||||||
+ `${CMAKE_INSTALL_DOCDIR}/${project}/html`.
|
|
||||||
|
|
||||||
**LLVM_INSTALL_OCAMLDOC_HTML_DIR**:STRING
|
|
||||||
The path to install OCamldoc-generated HTML documentation to. This path can
|
|
||||||
- either be absolute or relative to the CMAKE_INSTALL_PREFIX. Defaults to
|
|
||||||
- `share/doc/llvm/ocaml-html`.
|
|
||||||
+ either be absolute or relative to the ``CMAKE_INSTALL_PREFIX``. Defaults to
|
|
||||||
+ `${CMAKE_INSTALL_DOCDIR}/${project}/ocaml-html`.
|
|
||||||
+
|
|
||||||
+**CMAKE_INSTALL_BINDIR**:STRING
|
|
||||||
+ The path to install binary tools, relative to the ``CMAKE_INSTALL_PREFIX``.
|
|
||||||
+ Defaults to `bin`.
|
|
||||||
+
|
|
||||||
+**CMAKE_INSTALL_LIBDIR**:STRING
|
|
||||||
+ The path to install libraries, relative to the ``CMAKE_INSTALL_PREFIX``.
|
|
||||||
+ Defaults to `lib`.
|
|
||||||
+
|
|
||||||
+**CMAKE_INSTALL_INCLUDEDIR**:STRING
|
|
||||||
+ The path to install header files, relative to the ``CMAKE_INSTALL_PREFIX``.
|
|
||||||
+ Defaults to `include`.
|
|
||||||
+
|
|
||||||
+**CMAKE_INSTALL_DOCDIR**:STRING
|
|
||||||
+ The path to install documentation, relative to the ``CMAKE_INSTALL_PREFIX``.
|
|
||||||
+ Defaults to `share/doc`.
|
|
||||||
+
|
|
||||||
+**CMAKE_INSTALL_MANDIR**:STRING
|
|
||||||
+ The path to install manpage files, relative to the ``CMAKE_INSTALL_PREFIX``.
|
|
||||||
+ Defaults to `share/man`.
|
|
||||||
|
|
||||||
**LLVM_CREATE_XCODE_TOOLCHAIN**:BOOL
|
|
||||||
macOS Only: If enabled CMake will generate a target named
|
|
||||||
@@ -752,9 +772,11 @@ the ``cmake`` command or by setting it directly in ``ccmake`` or ``cmake-gui``).
|
|
||||||
|
|
||||||
This file is available in two different locations.
|
|
||||||
|
|
||||||
-* ``<INSTALL_PREFIX>/lib/cmake/llvm/LLVMConfig.cmake`` where
|
|
||||||
- ``<INSTALL_PREFIX>`` is the install prefix of an installed version of LLVM.
|
|
||||||
- On Linux typically this is ``/usr/lib/cmake/llvm/LLVMConfig.cmake``.
|
|
||||||
+* ``<LLVM_INSTALL_PACKAGE_DIR>LLVMConfig.cmake`` where
|
|
||||||
+ ``<LLVM_INSTALL_PACKAGE_DIR>`` is the location where LLVM CMake modules are
|
|
||||||
+ installed as part of an installed version of LLVM. This is typically
|
|
||||||
+ ``cmake/llvm/`` within the lib directory. On Linux, this is typically
|
|
||||||
+ ``/usr/lib/cmake/llvm/LLVMConfig.cmake``.
|
|
||||||
|
|
||||||
* ``<LLVM_BUILD_ROOT>/lib/cmake/llvm/LLVMConfig.cmake`` where
|
|
||||||
``<LLVM_BUILD_ROOT>`` is the root of the LLVM build tree. **Note: this is only
|
|
||||||
diff --git a/examples/Bye/CMakeLists.txt b/examples/Bye/CMakeLists.txt
|
|
||||||
index bb96edb4b4bf..678c22fb43c8 100644
|
|
||||||
--- a/examples/Bye/CMakeLists.txt
|
|
||||||
+++ b/examples/Bye/CMakeLists.txt
|
|
||||||
@@ -14,6 +14,6 @@ if (NOT WIN32)
|
|
||||||
BUILDTREE_ONLY
|
|
||||||
)
|
|
||||||
|
|
||||||
- install(TARGETS ${name} RUNTIME DESTINATION examples)
|
|
||||||
+ install(TARGETS ${name} RUNTIME DESTINATION ${CMAKE_INSTALL_DOCDIR}/examples)
|
|
||||||
set_target_properties(${name} PROPERTIES FOLDER "Examples")
|
|
||||||
endif()
|
|
||||||
diff --git a/include/llvm/CMakeLists.txt b/include/llvm/CMakeLists.txt
|
|
||||||
index b46319f24fc8..2feabd1954e4 100644
|
|
||||||
--- a/include/llvm/CMakeLists.txt
|
|
||||||
+++ b/include/llvm/CMakeLists.txt
|
|
||||||
@@ -5,5 +5,5 @@ add_subdirectory(Frontend)
|
|
||||||
# If we're doing an out-of-tree build, copy a module map for generated
|
|
||||||
# header files into the build area.
|
|
||||||
if (NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
|
|
||||||
- configure_file(module.modulemap.build module.modulemap COPYONLY)
|
|
||||||
+ configure_file(module.modulemap.build ${LLVM_INCLUDE_DIR}/module.modulemap COPYONLY)
|
|
||||||
endif (NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
|
|
||||||
diff --git a/tools/llvm-config/BuildVariables.inc.in b/tools/llvm-config/BuildVariables.inc.in
|
|
||||||
index 63cef75368b7..6295478b1f3d 100644
|
|
||||||
--- a/tools/llvm-config/BuildVariables.inc.in
|
|
||||||
+++ b/tools/llvm-config/BuildVariables.inc.in
|
|
||||||
@@ -23,6 +23,10 @@
|
|
||||||
#define LLVM_CXXFLAGS "@LLVM_CXXFLAGS@"
|
|
||||||
#define LLVM_BUILDMODE "@LLVM_BUILDMODE@"
|
|
||||||
#define LLVM_LIBDIR_SUFFIX "@LLVM_LIBDIR_SUFFIX@"
|
|
||||||
+#define LLVM_INSTALL_BINDIR "@CMAKE_INSTALL_BINDIR@"
|
|
||||||
+#define LLVM_INSTALL_LIBDIR "@CMAKE_INSTALL_LIBDIR@"
|
|
||||||
+#define LLVM_INSTALL_INCLUDEDIR "@CMAKE_INSTALL_INCLUDEDIR@"
|
|
||||||
+#define LLVM_INSTALL_CMAKEDIR "@LLVM_INSTALL_CMAKE_DIR@"
|
|
||||||
#define LLVM_TARGETS_BUILT "@LLVM_TARGETS_BUILT@"
|
|
||||||
#define LLVM_SYSTEM_LIBS "@LLVM_SYSTEM_LIBS@"
|
|
||||||
#define LLVM_BUILD_SYSTEM "@LLVM_BUILD_SYSTEM@"
|
|
||||||
diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
|
|
||||||
index 7e74b7c90816..f185e9283f83 100644
|
|
||||||
--- a/tools/llvm-config/llvm-config.cpp
|
|
||||||
+++ b/tools/llvm-config/llvm-config.cpp
|
|
||||||
@@ -358,12 +358,26 @@ int main(int argc, char **argv) {
|
|
||||||
("-I" + ActiveIncludeDir + " " + "-I" + ActiveObjRoot + "/include");
|
|
||||||
} else {
|
|
||||||
ActivePrefix = CurrentExecPrefix;
|
|
||||||
- ActiveIncludeDir = ActivePrefix + "/include";
|
|
||||||
- SmallString<256> path(StringRef(LLVM_TOOLS_INSTALL_DIR));
|
|
||||||
- sys::fs::make_absolute(ActivePrefix, path);
|
|
||||||
- ActiveBinDir = std::string(path.str());
|
|
||||||
- ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
|
|
||||||
- ActiveCMakeDir = ActiveLibDir + "/cmake/llvm";
|
|
||||||
+ {
|
|
||||||
+ SmallString<256> path(StringRef(LLVM_INSTALL_INCLUDEDIR));
|
|
||||||
+ sys::fs::make_absolute(ActivePrefix, path);
|
|
||||||
+ ActiveIncludeDir = std::string(path.str());
|
|
||||||
+ }
|
|
||||||
+ {
|
|
||||||
+ SmallString<256> path(StringRef(LLVM_INSTALL_BINDIR));
|
|
||||||
+ sys::fs::make_absolute(ActivePrefix, path);
|
|
||||||
+ ActiveBinDir = std::string(path.str());
|
|
||||||
+ }
|
|
||||||
+ {
|
|
||||||
+ SmallString<256> path(StringRef(LLVM_INSTALL_LIBDIR LLVM_LIBDIR_SUFFIX));
|
|
||||||
+ sys::fs::make_absolute(ActivePrefix, path);
|
|
||||||
+ ActiveLibDir = std::string(path.str());
|
|
||||||
+ }
|
|
||||||
+ {
|
|
||||||
+ SmallString<256> path(StringRef(LLVM_INSTALL_CMAKEDIR));
|
|
||||||
+ sys::fs::make_absolute(ActivePrefix, path);
|
|
||||||
+ ActiveCMakeDir = std::string(path.str());
|
|
||||||
+ }
|
|
||||||
ActiveIncludeOption = "-I" + ActiveIncludeDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/tools/lto/CMakeLists.txt b/tools/lto/CMakeLists.txt
|
|
||||||
index 2963f97cad88..69d66c9c9ca1 100644
|
|
||||||
--- a/tools/lto/CMakeLists.txt
|
|
||||||
+++ b/tools/lto/CMakeLists.txt
|
|
||||||
@@ -25,7 +25,7 @@ add_llvm_library(LTO SHARED INSTALL_WITH_TOOLCHAIN ${SOURCES} DEPENDS
|
|
||||||
intrinsics_gen)
|
|
||||||
|
|
||||||
install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/lto.h
|
|
||||||
- DESTINATION include/llvm-c
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/llvm-c
|
|
||||||
COMPONENT LTO)
|
|
||||||
|
|
||||||
if (APPLE)
|
|
||||||
diff --git a/tools/opt-viewer/CMakeLists.txt b/tools/opt-viewer/CMakeLists.txt
|
|
||||||
index ead73ec13a8f..250362021f17 100644
|
|
||||||
--- a/tools/opt-viewer/CMakeLists.txt
|
|
||||||
+++ b/tools/opt-viewer/CMakeLists.txt
|
|
||||||
@@ -8,7 +8,7 @@ set (files
|
|
||||||
|
|
||||||
foreach (file ${files})
|
|
||||||
install(PROGRAMS ${file}
|
|
||||||
- DESTINATION share/opt-viewer
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/opt-viewer
|
|
||||||
COMPONENT opt-viewer)
|
|
||||||
endforeach (file)
|
|
||||||
|
|
||||||
diff --git a/tools/remarks-shlib/CMakeLists.txt b/tools/remarks-shlib/CMakeLists.txt
|
|
||||||
index e948496c603a..1f4df8a98b10 100644
|
|
||||||
--- a/tools/remarks-shlib/CMakeLists.txt
|
|
||||||
+++ b/tools/remarks-shlib/CMakeLists.txt
|
|
||||||
@@ -11,7 +11,7 @@ set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/Remarks.exports)
|
|
||||||
add_llvm_library(Remarks SHARED INSTALL_WITH_TOOLCHAIN ${SOURCES})
|
|
||||||
|
|
||||||
install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/Remarks.h
|
|
||||||
- DESTINATION include/llvm-c
|
|
||||||
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/llvm-c
|
|
||||||
COMPONENT Remarks)
|
|
||||||
|
|
||||||
if (APPLE)
|
|
|
@ -1,35 +0,0 @@
|
||||||
From 5c571082fdaf61f6df19d9b7137dc26d71334058 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Natanael Copa <ncopa@alpinelinux.org>
|
|
||||||
Date: Thu, 18 Feb 2016 10:33:04 +0100
|
|
||||||
Subject: [PATCH 2/3] Fix build with musl libc
|
|
||||||
|
|
||||||
On musl libc the fopen64 and fopen are the same thing, but for
|
|
||||||
compatibility they have a `#define fopen64 fopen`. Same applies for
|
|
||||||
fseek64, fstat64, fstatvfs64, ftello64, lstat64, stat64 and tmpfile64.
|
|
||||||
---
|
|
||||||
include/llvm/Analysis/TargetLibraryInfo.h | 9 +++++++++
|
|
||||||
1 file changed, 9 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/include/llvm/Analysis/TargetLibraryInfo.h b/include/llvm/Analysis/TargetLibraryInfo.h
|
|
||||||
index 7becdf0..7f14427 100644
|
|
||||||
--- a/include/llvm/Analysis/TargetLibraryInfo.h
|
|
||||||
+++ b/include/llvm/Analysis/TargetLibraryInfo.h
|
|
||||||
@@ -18,6 +18,15 @@
|
|
||||||
#include "llvm/IR/Module.h"
|
|
||||||
#include "llvm/Pass.h"
|
|
||||||
|
|
||||||
+#undef fopen64
|
|
||||||
+#undef fseeko64
|
|
||||||
+#undef fstat64
|
|
||||||
+#undef fstatvfs64
|
|
||||||
+#undef ftello64
|
|
||||||
+#undef lstat64
|
|
||||||
+#undef stat64
|
|
||||||
+#undef tmpfile64
|
|
||||||
+
|
|
||||||
namespace llvm {
|
|
||||||
/// VecDesc - Describes a possible vectorization of a function.
|
|
||||||
/// Function 'VectorFnName' is equivalent to 'ScalarFnName' vectorized
|
|
||||||
--
|
|
||||||
2.7.3
|
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
--- lib/Support/Unix/Memory.inc
|
|
||||||
+++ lib/Support/Unix/Memory.inc
|
|
||||||
@@ -126,8 +126,12 @@
|
|
||||||
Result.Address = Addr;
|
|
||||||
Result.Size = NumPages*PageSize;
|
|
||||||
|
|
||||||
- if (PFlags & MF_EXEC)
|
|
||||||
- Memory::InvalidateInstructionCache(Result.Address, Result.Size);
|
|
||||||
+ // Rely on protectMappedMemory to invalidate instruction cache.
|
|
||||||
+ if (PFlags & MF_EXEC) {
|
|
||||||
+ EC = Memory::protectMappedMemory (Result, PFlags);
|
|
||||||
+ if (EC != std::error_code())
|
|
||||||
+ return MemoryBlock();
|
|
||||||
+ }
|
|
||||||
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
@@ -156,15 +160,31 @@
|
|
||||||
return std::error_code(EINVAL, std::generic_category());
|
|
||||||
|
|
||||||
int Protect = getPosixProtectionFlags(Flags);
|
|
||||||
-
|
|
||||||
uintptr_t Start = alignAddr((uint8_t *)M.Address - PageSize + 1, PageSize);
|
|
||||||
uintptr_t End = alignAddr((uint8_t *)M.Address + M.Size, PageSize);
|
|
||||||
+
|
|
||||||
+ bool InvalidateCache = (Flags & MF_EXEC);
|
|
||||||
+
|
|
||||||
+#if defined(__arm__) || defined(__aarch64__)
|
|
||||||
+ // Certain ARM implementations treat icache clear instruction as a memory read,
|
|
||||||
+ // and CPU segfaults on trying to clear cache on !PROT_READ page. Therefore we need
|
|
||||||
+ // to temporarily add PROT_READ for the sake of flushing the instruction caches.
|
|
||||||
+ if (InvalidateCache && !(Protect & PROT_READ)) {
|
|
||||||
+ int Result = ::mprotect((void *)Start, End - Start, Protect | PROT_READ);
|
|
||||||
+ if (Result != 0)
|
|
||||||
+ return std::error_code(errno, std::generic_category());
|
|
||||||
+
|
|
||||||
+ Memory::InvalidateInstructionCache(M.Address, M.Size);
|
|
||||||
+ InvalidateCache = false;
|
|
||||||
+ }
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
int Result = ::mprotect((void *)Start, End - Start, Protect);
|
|
||||||
|
|
||||||
if (Result != 0)
|
|
||||||
return std::error_code(errno, std::generic_category());
|
|
||||||
|
|
||||||
- if (Flags & MF_EXEC)
|
|
||||||
+ if (InvalidateCache)
|
|
||||||
Memory::InvalidateInstructionCache(M.Address, M.Size);
|
|
||||||
|
|
||||||
return std::error_code();
|
|
|
@ -1,13 +0,0 @@
|
||||||
diff --git a/lib/Driver/ToolChains/CommonArgs.cpp b/lib/Driver/ToolChains/CommonArgs.cpp
|
|
||||||
index 6b6e276b8ce7..7896542a1202 100644
|
|
||||||
--- a/lib/Driver/ToolChains/CommonArgs.cpp
|
|
||||||
+++ b/lib/Driver/ToolChains/CommonArgs.cpp
|
|
||||||
@@ -409,7 +409,7 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
|
|
||||||
|
|
||||||
SmallString<1024> Plugin;
|
|
||||||
llvm::sys::path::native(
|
|
||||||
- Twine(D.Dir) + "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold" + Suffix,
|
|
||||||
+ Twine("@libllvmLibdir@" "/LLVMgold") + Suffix,
|
|
||||||
Plugin);
|
|
||||||
CmdArgs.push_back(Args.MakeArgString(Plugin));
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
diff --git a/lib/Driver/ToolChains/CommonArgs.cpp b/lib/Driver/ToolChains/CommonArgs.cpp
|
|
||||||
index 37ec73468570..b73e75aa6e59 100644
|
|
||||||
--- a/lib/Driver/ToolChains/CommonArgs.cpp
|
|
||||||
+++ b/lib/Driver/ToolChains/CommonArgs.cpp
|
|
||||||
@@ -370,8 +370,8 @@ void tools::AddGoldPlugin(const ToolChain &ToolChain, const ArgList &Args,
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SmallString<1024> Plugin;
|
|
||||||
- llvm::sys::path::native(Twine(ToolChain.getDriver().Dir) +
|
|
||||||
- "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold" +
|
|
||||||
+ llvm::sys::path::native(Twine("@libllvmLibdir@"
|
|
||||||
+ "/LLVMgold") +
|
|
||||||
Suffix,
|
|
||||||
Plugin);
|
|
||||||
CmdArgs.push_back(Args.MakeArgString(Plugin));
|
|
|
@ -1,48 +0,0 @@
|
||||||
{ lib, runCommand, stdenv, llvm, lld, version, release_version }:
|
|
||||||
|
|
||||||
let
|
|
||||||
targetPrefix = lib.optionalString (stdenv.hostPlatform != stdenv.targetPlatform) "${stdenv.targetPlatform.config}-";
|
|
||||||
in
|
|
||||||
runCommand "llvm-binutils-${version}"
|
|
||||||
{
|
|
||||||
preferLocalBuild = true;
|
|
||||||
passthru = {
|
|
||||||
isLLVM = true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
(''
|
|
||||||
mkdir -p $out/bin
|
|
||||||
for prog in ${lld}/bin/*; do
|
|
||||||
ln -s $prog $out/bin/${targetPrefix}$(basename $prog)
|
|
||||||
done
|
|
||||||
for prog in ${llvm}/bin/*; do
|
|
||||||
ln -sf $prog $out/bin/${targetPrefix}$(basename $prog)
|
|
||||||
done
|
|
||||||
|
|
||||||
llvmBin="${llvm}/bin"
|
|
||||||
|
|
||||||
ln -s $llvmBin/llvm-ar $out/bin/${targetPrefix}ar
|
|
||||||
ln -s $llvmBin/llvm-ar $out/bin/${targetPrefix}dlltool
|
|
||||||
ln -s $llvmBin/llvm-ar $out/bin/${targetPrefix}ranlib
|
|
||||||
ln -s $llvmBin/llvm-cxxfilt $out/bin/${targetPrefix}c++filt
|
|
||||||
ln -s $llvmBin/llvm-dwp $out/bin/${targetPrefix}dwp
|
|
||||||
ln -s $llvmBin/llvm-nm $out/bin/${targetPrefix}nm
|
|
||||||
ln -s $llvmBin/llvm-objcopy $out/bin/${targetPrefix}objcopy
|
|
||||||
ln -s $llvmBin/llvm-objcopy $out/bin/${targetPrefix}strip
|
|
||||||
ln -s $llvmBin/llvm-objdump $out/bin/${targetPrefix}objdump
|
|
||||||
ln -s $llvmBin/llvm-readobj $out/bin/${targetPrefix}readelf
|
|
||||||
ln -s $llvmBin/llvm-size $out/bin/${targetPrefix}size
|
|
||||||
ln -s $llvmBin/llvm-strings $out/bin/${targetPrefix}strings
|
|
||||||
ln -s $llvmBin/llvm-symbolizer $out/bin/${targetPrefix}addr2line
|
|
||||||
|
|
||||||
if [ -e "$llvmBin/llvm-debuginfod" ]; then
|
|
||||||
ln -s $llvmBin/llvm-debuginfod $out/bin/${targetPrefix}debuginfod
|
|
||||||
ln -s $llvmBin/llvm-debuginfod-find $out/bin/${targetPrefix}debuginfod-find
|
|
||||||
fi
|
|
||||||
|
|
||||||
ln -s ${lld}/bin/lld $out/bin/${targetPrefix}ld
|
|
||||||
|
|
||||||
# Only >=13 show GNU windres compatible in help
|
|
||||||
'' + lib.optionalString (lib.versionAtLeast release_version "13") ''
|
|
||||||
ln -s $llvmBin/llvm-rc $out/bin/${targetPrefix}windres
|
|
||||||
'')
|
|
|
@ -1,30 +0,0 @@
|
||||||
From 4add81bba40dcec62c4ea4481be8e35ac53e89d8 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Will Dietz <w@wdtz.org>
|
|
||||||
Date: Thu, 18 May 2017 11:56:12 -0500
|
|
||||||
Subject: [PATCH] "purity" patch for 5.0
|
|
||||||
|
|
||||||
---
|
|
||||||
lib/Driver/ToolChains/Gnu.cpp | 7 -------
|
|
||||||
1 file changed, 7 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp
|
|
||||||
index fe3c0191bb..c6a482bece 100644
|
|
||||||
--- a/lib/Driver/ToolChains/Gnu.cpp
|
|
||||||
+++ b/lib/Driver/ToolChains/Gnu.cpp
|
|
||||||
@@ -494,13 +494,6 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
|
||||||
if (!Args.hasArg(options::OPT_static)) {
|
|
||||||
if (Args.hasArg(options::OPT_rdynamic))
|
|
||||||
CmdArgs.push_back("-export-dynamic");
|
|
||||||
-
|
|
||||||
- if (!Args.hasArg(options::OPT_shared)) {
|
|
||||||
- const std::string Loader =
|
|
||||||
- D.DyldPrefix + ToolChain.getDynamicLinker(Args);
|
|
||||||
- CmdArgs.push_back("-dynamic-linker");
|
|
||||||
- CmdArgs.push_back(Args.MakeArgString(Loader));
|
|
||||||
- }
|
|
||||||
}
|
|
||||||
|
|
||||||
CmdArgs.push_back("-o");
|
|
||||||
--
|
|
||||||
2.11.0
|
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
|
|
||||||
index 3f29afd35971..223d2769cdfc 100644
|
|
||||||
--- a/lib/Driver/Driver.cpp
|
|
||||||
+++ b/lib/Driver/Driver.cpp
|
|
||||||
@@ -491,6 +491,13 @@ DerivedArgList *Driver::TranslateInputArgs(const InputArgList &Args) const {
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
+ {
|
|
||||||
+ Arg *A = DAL->MakeFlagArg(/*BaseArg=*/nullptr,
|
|
||||||
+ Opts.getOption(options::OPT_nostdlibinc));
|
|
||||||
+ A->claim();
|
|
||||||
+ DAL->append(A);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
return DAL;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,196 +0,0 @@
|
||||||
{ lib
|
|
||||||
, stdenv
|
|
||||||
, llvm_meta
|
|
||||||
, release_version
|
|
||||||
, cmake
|
|
||||||
, zlib
|
|
||||||
, ncurses
|
|
||||||
, swig
|
|
||||||
, which
|
|
||||||
, libedit
|
|
||||||
, libxml2
|
|
||||||
, libllvm
|
|
||||||
, libclang
|
|
||||||
, python3
|
|
||||||
, version
|
|
||||||
, darwin
|
|
||||||
, lit
|
|
||||||
, makeWrapper
|
|
||||||
, lua5_3
|
|
||||||
, ninja
|
|
||||||
, runCommand
|
|
||||||
, src ? null
|
|
||||||
, monorepoSrc ? null
|
|
||||||
, patches ? [ ]
|
|
||||||
, enableManpages ? false
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
|
||||||
src' =
|
|
||||||
if monorepoSrc != null then
|
|
||||||
runCommand "lldb-src-${version}" { } ''
|
|
||||||
mkdir -p "$out"
|
|
||||||
cp -r ${monorepoSrc}/cmake "$out"
|
|
||||||
cp -r ${monorepoSrc}/lldb "$out"
|
|
||||||
'' else src;
|
|
||||||
in
|
|
||||||
|
|
||||||
stdenv.mkDerivation (rec {
|
|
||||||
passthru.monorepoSrc = monorepoSrc;
|
|
||||||
pname = "lldb";
|
|
||||||
inherit version;
|
|
||||||
|
|
||||||
src = src';
|
|
||||||
inherit patches;
|
|
||||||
|
|
||||||
outputs = [ "out" "lib" "dev" ];
|
|
||||||
|
|
||||||
sourceRoot = lib.optional (lib.versionAtLeast release_version "13") "${src.name}/${pname}";
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
|
||||||
cmake
|
|
||||||
python3
|
|
||||||
which
|
|
||||||
swig
|
|
||||||
lit
|
|
||||||
makeWrapper
|
|
||||||
lua5_3
|
|
||||||
] ++ lib.optionals enableManpages [
|
|
||||||
python3.pkgs.sphinx
|
|
||||||
python3.pkgs.recommonmark
|
|
||||||
] ++ lib.optionals (lib.versionAtLeast release_version "14") [
|
|
||||||
ninja
|
|
||||||
];
|
|
||||||
|
|
||||||
buildInputs = [
|
|
||||||
ncurses
|
|
||||||
zlib
|
|
||||||
libedit
|
|
||||||
libxml2
|
|
||||||
libllvm
|
|
||||||
] ++ lib.optionals stdenv.isDarwin [
|
|
||||||
darwin.libobjc
|
|
||||||
darwin.apple_sdk.libs.xpc
|
|
||||||
darwin.apple_sdk.frameworks.Foundation
|
|
||||||
darwin.bootstrap_cmds
|
|
||||||
darwin.apple_sdk.frameworks.Carbon
|
|
||||||
darwin.apple_sdk.frameworks.Cocoa
|
|
||||||
]
|
|
||||||
# The older libSystem used on x86_64 macOS is missing the
|
|
||||||
# `<bsm/audit_session.h>` header which `lldb` uses.
|
|
||||||
#
|
|
||||||
# We copy this header over from macOS 10.12 SDK.
|
|
||||||
#
|
|
||||||
# See here for context:
|
|
||||||
# https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132
|
|
||||||
++ lib.optional
|
|
||||||
(
|
|
||||||
stdenv.targetPlatform.isDarwin
|
|
||||||
&& !stdenv.targetPlatform.isAarch64
|
|
||||||
&& (lib.versionAtLeast release_version "15")
|
|
||||||
)
|
|
||||||
(
|
|
||||||
runCommand "bsm-audit-session-header" { } ''
|
|
||||||
install -Dm444 \
|
|
||||||
"${lib.getDev darwin.apple_sdk.sdk}/include/bsm/audit_session.h" \
|
|
||||||
"$out/include/bsm/audit_session.h"
|
|
||||||
''
|
|
||||||
);
|
|
||||||
|
|
||||||
hardeningDisable = [ "format" ];
|
|
||||||
|
|
||||||
cmakeFlags = [
|
|
||||||
"-DLLDB_INCLUDE_TESTS=${if doCheck then "YES" else "NO"}"
|
|
||||||
"-DLLVM_ENABLE_RTTI=OFF"
|
|
||||||
"-DClang_DIR=${lib.getDev libclang}/lib/cmake"
|
|
||||||
"-DLLVM_EXTERNAL_LIT=${lit}/bin/lit"
|
|
||||||
] ++ lib.optionals stdenv.isDarwin [
|
|
||||||
"-DLLDB_USE_SYSTEM_DEBUGSERVER=ON"
|
|
||||||
] ++ lib.optionals (!stdenv.isDarwin) [
|
|
||||||
"-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic
|
|
||||||
] ++ lib.optionals enableManpages ([
|
|
||||||
"-DLLVM_ENABLE_SPHINX=ON"
|
|
||||||
"-DSPHINX_OUTPUT_MAN=ON"
|
|
||||||
"-DSPHINX_OUTPUT_HTML=OFF"
|
|
||||||
] ++ lib.optionals (lib.versionAtLeast release_version "15") [
|
|
||||||
# docs reference `automodapi` but it's not added to the extensions list when
|
|
||||||
# only building the manpages:
|
|
||||||
# https://github.com/llvm/llvm-project/blob/af6ec9200b09039573d85e349496c4f5b17c3d7f/lldb/docs/conf.py#L54
|
|
||||||
#
|
|
||||||
# so, we just ignore the resulting errors
|
|
||||||
"-DSPHINX_WARNINGS_AS_ERRORS=OFF"
|
|
||||||
]) ++ lib.optionals doCheck [
|
|
||||||
"-DLLDB_TEST_C_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"
|
|
||||||
"-DLLDB_TEST_CXX_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++"
|
|
||||||
];
|
|
||||||
|
|
||||||
doCheck = false;
|
|
||||||
doInstallCheck = lib.versionOlder release_version "15";
|
|
||||||
|
|
||||||
# TODO: cleanup with mass-rebuild
|
|
||||||
installCheckPhase = ''
|
|
||||||
if [ ! -e $lib/${python3.sitePackages}/lldb/_lldb*.so ] ; then
|
|
||||||
echo "ERROR: python files not installed where expected!";
|
|
||||||
return 1;
|
|
||||||
fi
|
|
||||||
'' # Something lua is built on older versions but this file doesn't exist.
|
|
||||||
+ lib.optionalString (lib.versionAtLeast release_version "14") ''
|
|
||||||
if [ ! -e "$lib/lib/lua/${lua5_3.luaversion}/lldb.so" ] ; then
|
|
||||||
echo "ERROR: lua files not installed where expected!";
|
|
||||||
return 1;
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
|
|
||||||
postInstall = ''
|
|
||||||
wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/
|
|
||||||
|
|
||||||
# Editor support
|
|
||||||
# vscode:
|
|
||||||
install -D ../tools/lldb-vscode/package.json $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/package.json
|
|
||||||
mkdir -p $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin
|
|
||||||
ln -s $out/bin/*-vscode $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin
|
|
||||||
'';
|
|
||||||
|
|
||||||
meta = llvm_meta // {
|
|
||||||
homepage = "https://lldb.llvm.org/";
|
|
||||||
description = "A next-generation high-performance debugger";
|
|
||||||
longDescription = ''
|
|
||||||
LLDB is a next generation, high-performance debugger. It is built as a set
|
|
||||||
of reusable components which highly leverage existing libraries in the
|
|
||||||
larger LLVM Project, such as the Clang expression parser and LLVM
|
|
||||||
disassembler.
|
|
||||||
'';
|
|
||||||
# llvm <10 never built on aarch64-darwin since first introduction in nixpkgs
|
|
||||||
broken =
|
|
||||||
(lib.versionOlder release_version "11" && stdenv.isDarwin && stdenv.isAarch64)
|
|
||||||
|| (((lib.versions.major release_version) == "13") && stdenv.isDarwin);
|
|
||||||
};
|
|
||||||
} // lib.optionalAttrs enableManpages {
|
|
||||||
pname = "lldb-manpages";
|
|
||||||
|
|
||||||
buildPhase = lib.optionalString (lib.versionOlder release_version "15") ''
|
|
||||||
make ${if (lib.versionOlder release_version "12") then "docs-man" else "docs-lldb-man"}
|
|
||||||
'';
|
|
||||||
|
|
||||||
|
|
||||||
ninjaFlags = lib.optionals (lib.versionAtLeast release_version "15") [ "docs-lldb-man" ];
|
|
||||||
|
|
||||||
propagatedBuildInputs = [ ];
|
|
||||||
|
|
||||||
# manually install lldb man page
|
|
||||||
installPhase = ''
|
|
||||||
mkdir -p $out/share/man/man1
|
|
||||||
install docs/man/lldb.1 -t $out/share/man/man1/
|
|
||||||
'';
|
|
||||||
|
|
||||||
postPatch = null;
|
|
||||||
postInstall = null;
|
|
||||||
|
|
||||||
outputs = [ "out" ];
|
|
||||||
|
|
||||||
doCheck = false;
|
|
||||||
|
|
||||||
meta = llvm_meta // {
|
|
||||||
description = "man pages for LLDB ${version}";
|
|
||||||
};
|
|
||||||
})
|
|
|
@ -1,11 +0,0 @@
|
||||||
diff --git a/test/tools/llvm-exegesis/X86/uops-CMOV16rm-noreg.s b/test/tools/llvm-exegesis/X86/uops-CMOV16rm-noreg.s
|
|
||||||
index 3fc1f31d54dc..a4c9bdd92131 100644
|
|
||||||
--- a/test/tools/llvm-exegesis/X86/uops-CMOV16rm-noreg.s
|
|
||||||
+++ b/test/tools/llvm-exegesis/X86/uops-CMOV16rm-noreg.s
|
|
||||||
@@ -1,5 +1,6 @@
|
|
||||||
# RUN: llvm-exegesis -mode=uops -opcode-name=CMOV16rm -benchmarks-file=%t.CMOV16rm-uops.yaml
|
|
||||||
# RUN: FileCheck -check-prefixes=CHECK-YAML -input-file=%t.CMOV16rm-uops.yaml %s
|
|
||||||
+# RUN: sed -i 's,cpu_name:.*,cpu_name: bdver2,g' %t.CMOV16rm-uops.yaml
|
|
||||||
# RUN: llvm-exegesis -mcpu=bdver2 -mode=analysis -benchmarks-file=%t.CMOV16rm-uops.yaml -analysis-clusters-output-file=- -analysis-clustering-epsilon=0.1 -analysis-inconsistency-epsilon=0.1 -analysis-numpoints=1 -analysis-clustering=naive | FileCheck -check-prefixes=CHECK-CLUSTERS %s
|
|
||||||
|
|
||||||
# https://bugs.llvm.org/show_bug.cgi?id=41448
|
|
|
@ -1,39 +0,0 @@
|
||||||
From 1c936d7fda3275265e37f93697232a1ed652390f Mon Sep 17 00:00:00 2001
|
|
||||||
From: Will Dietz <w@wdtz.org>
|
|
||||||
Date: Sat, 9 Jul 2016 19:22:54 -0500
|
|
||||||
Subject: [PATCH] musl fixes/hacks
|
|
||||||
|
|
||||||
Conflicts:
|
|
||||||
|
|
||||||
include/__config
|
|
||||||
include/locale
|
|
||||||
src/locale.cpp
|
|
||||||
---
|
|
||||||
include/locale | 4 ++--
|
|
||||||
1 files changed, 2 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/include/locale b/include/locale
|
|
||||||
index 3d804e8..9b01f5b 100644
|
|
||||||
--- a/include/locale
|
|
||||||
+++ b/include/locale
|
|
||||||
@@ -695,7 +695,7 @@ __num_get_signed_integral(const char* __a, const char* __a_end,
|
|
||||||
typename remove_reference<decltype(errno)>::type __save_errno = errno;
|
|
||||||
errno = 0;
|
|
||||||
char *__p2;
|
|
||||||
- long long __ll = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
|
|
||||||
+ long long __ll = strtoll(__a, &__p2, __base);
|
|
||||||
typename remove_reference<decltype(errno)>::type __current_errno = errno;
|
|
||||||
if (__current_errno == 0)
|
|
||||||
errno = __save_errno;
|
|
||||||
@@ -735,7 +735,7 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end,
|
|
||||||
typename remove_reference<decltype(errno)>::type __save_errno = errno;
|
|
||||||
errno = 0;
|
|
||||||
char *__p2;
|
|
||||||
- unsigned long long __ll = strtoull_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
|
|
||||||
+ unsigned long long __ll = strtoull(__a, &__p2, __base);
|
|
||||||
typename remove_reference<decltype(errno)>::type __current_errno = errno;
|
|
||||||
if (__current_errno == 0)
|
|
||||||
errno = __save_errno;
|
|
||||||
--
|
|
||||||
1.7.1
|
|
||||||
|
|
|
@ -1,92 +0,0 @@
|
||||||
From 8c747d3157df2830eed9205e7caf1203b345de17 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Khem Raj <raj.khem@gmail.com>
|
|
||||||
Date: Sat, 4 Feb 2023 13:54:41 -0800
|
|
||||||
Subject: [PATCH] cmake: Enable 64bit off_t on 32bit glibc systems
|
|
||||||
|
|
||||||
Pass -D_FILE_OFFSET_BITS=64 to compiler flags on 32bit glibc based
|
|
||||||
systems. This will make sure that 64bit versions of LFS functions are
|
|
||||||
used e.g. seek will behave same as lseek64. Also revert [1] partially
|
|
||||||
because this added a cmake test to detect lseek64 but then forgot to
|
|
||||||
pass the needed macro to actual compile, this test was incomplete too
|
|
||||||
since libc implementations like musl has 64bit off_t by default on 32bit
|
|
||||||
systems and does not bundle[2] -D_LARGEFILE64_SOURCE under -D_GNU_SOURCE
|
|
||||||
like glibc, which means the compile now fails on musl because the cmake
|
|
||||||
check passes but we do not have _LARGEFILE64_SOURCE defined. Using the
|
|
||||||
*64 function was transitional anyways so use -D_FILE_OFFSET_BITS=64
|
|
||||||
instead
|
|
||||||
|
|
||||||
[1] https://github.com/llvm/llvm-project/commit/8db7e5e4eed4c4e697dc3164f2c9351d8c3e942b
|
|
||||||
[2] https://git.musl-libc.org/cgit/musl/commit/?id=25e6fee27f4a293728dd15b659170e7b9c7db9bc
|
|
||||||
|
|
||||||
Reviewed By: MaskRay
|
|
||||||
|
|
||||||
Differential Revision: https://reviews.llvm.org/D139752
|
|
||||||
|
|
||||||
(cherry picked from commit 5cd554303ead0f8891eee3cd6d25cb07f5a7bf67)
|
|
||||||
---
|
|
||||||
cmake/config-ix.cmake | 13 ++++++++++---
|
|
||||||
include/llvm/Config/config.h.cmake | 3 ---
|
|
||||||
lib/Support/raw_ostream.cpp | 2 --
|
|
||||||
3 files changed, 10 insertions(+), 8 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake
|
|
||||||
index 18977d9950ff..b558aa83fa62 100644
|
|
||||||
--- a/cmake/config-ix.cmake
|
|
||||||
+++ b/cmake/config-ix.cmake
|
|
||||||
@@ -197,9 +197,6 @@ check_symbol_exists(posix_fallocate fcntl.h HAVE_POSIX_FALLOCATE)
|
|
||||||
if( HAVE_SIGNAL_H AND NOT LLVM_USE_SANITIZER MATCHES ".*Address.*" AND NOT APPLE )
|
|
||||||
check_symbol_exists(sigaltstack signal.h HAVE_SIGALTSTACK)
|
|
||||||
endif()
|
|
||||||
-set(CMAKE_REQUIRED_DEFINITIONS "-D_LARGEFILE64_SOURCE")
|
|
||||||
-check_symbol_exists(lseek64 "sys/types.h;unistd.h" HAVE_LSEEK64)
|
|
||||||
-set(CMAKE_REQUIRED_DEFINITIONS "")
|
|
||||||
check_symbol_exists(mallctl malloc_np.h HAVE_MALLCTL)
|
|
||||||
check_symbol_exists(mallinfo malloc.h HAVE_MALLINFO)
|
|
||||||
check_symbol_exists(malloc_zone_statistics malloc/malloc.h
|
|
||||||
@@ -237,6 +234,16 @@ if( PURE_WINDOWS )
|
|
||||||
check_function_exists(__main HAVE___MAIN)
|
|
||||||
check_function_exists(__cmpdi2 HAVE___CMPDI2)
|
|
||||||
endif()
|
|
||||||
+
|
|
||||||
+check_symbol_exists(__GLIBC__ stdio.h LLVM_USING_GLIBC)
|
|
||||||
+if( LLVM_USING_GLIBC )
|
|
||||||
+# enable 64bit off_t on 32bit systems using glibc
|
|
||||||
+ if (CMAKE_SIZEOF_VOID_P EQUAL 4)
|
|
||||||
+ add_compile_definitions(_FILE_OFFSET_BITS=64)
|
|
||||||
+ list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_FILE_OFFSET_BITS=64")
|
|
||||||
+ endif()
|
|
||||||
+endif()
|
|
||||||
+
|
|
||||||
if( HAVE_DLFCN_H )
|
|
||||||
if( HAVE_LIBDL )
|
|
||||||
list(APPEND CMAKE_REQUIRED_LIBRARIES dl)
|
|
||||||
diff --git a/include/llvm/Config/config.h.cmake b/include/llvm/Config/config.h.cmake
|
|
||||||
index e934617d7ec7..3c39c373b3c1 100644
|
|
||||||
--- a/include/llvm/Config/config.h.cmake
|
|
||||||
+++ b/include/llvm/Config/config.h.cmake
|
|
||||||
@@ -112,9 +112,6 @@
|
|
||||||
/* Define to 1 if you have the <link.h> header file. */
|
|
||||||
#cmakedefine HAVE_LINK_H ${HAVE_LINK_H}
|
|
||||||
|
|
||||||
-/* Define to 1 if you have the `lseek64' function. */
|
|
||||||
-#cmakedefine HAVE_LSEEK64 ${HAVE_LSEEK64}
|
|
||||||
-
|
|
||||||
/* Define to 1 if you have the <mach/mach.h> header file. */
|
|
||||||
#cmakedefine HAVE_MACH_MACH_H ${HAVE_MACH_MACH_H}
|
|
||||||
|
|
||||||
diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp
|
|
||||||
index 038ad00bd608..921ab8409008 100644
|
|
||||||
--- a/lib/Support/raw_ostream.cpp
|
|
||||||
+++ b/lib/Support/raw_ostream.cpp
|
|
||||||
@@ -677,8 +677,6 @@ uint64_t raw_fd_ostream::seek(uint64_t off) {
|
|
||||||
flush();
|
|
||||||
#ifdef _WIN32
|
|
||||||
pos = ::_lseeki64(FD, off, SEEK_SET);
|
|
||||||
-#elif defined(HAVE_LSEEK64)
|
|
||||||
- pos = ::lseek64(FD, off, SEEK_SET);
|
|
||||||
#else
|
|
||||||
pos = ::lseek(FD, off, SEEK_SET);
|
|
||||||
#endif
|
|
||||||
--
|
|
||||||
2.37.1
|
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
diff --git llvm/tools/llvm-config/CMakeLists.txt llvm/tools/llvm-config/CMakeLists.txt
|
|
||||||
index 16ba54c0cf2f..20b017195e84 100644
|
|
||||||
--- llvm/tools/llvm-config/CMakeLists.txt
|
|
||||||
+++ llvm/tools/llvm-config/CMakeLists.txt
|
|
||||||
@@ -6,6 +6,7 @@ set(BUILDVARIABLES_OBJPATH ${CMAKE_CURRENT_BINARY_DIR}/BuildVariables.inc)
|
|
||||||
# Add the llvm-config tool.
|
|
||||||
add_llvm_tool(llvm-config
|
|
||||||
llvm-config.cpp
|
|
||||||
+ DISABLE_LLVM_LINK_LLVM_DYLIB
|
|
||||||
)
|
|
||||||
|
|
||||||
# Compute the substitution values for various items.
|
|
|
@ -1,60 +0,0 @@
|
||||||
{ runCommand,
|
|
||||||
clang,
|
|
||||||
gcc64,
|
|
||||||
gcc32,
|
|
||||||
glibc_multi
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
|
||||||
combine = basegcc: runCommand "combine-gcc-libc" {} ''
|
|
||||||
mkdir -p $out
|
|
||||||
cp -r ${basegcc.cc}/lib $out/lib
|
|
||||||
|
|
||||||
chmod u+rw -R $out/lib
|
|
||||||
cp -r ${basegcc.libc}/lib/* $(ls -d $out/lib/gcc/*/*)
|
|
||||||
'';
|
|
||||||
gcc_multi_sysroot = runCommand "gcc-multi-sysroot" {
|
|
||||||
passthru = {
|
|
||||||
inherit (gcc64) version;
|
|
||||||
lib = gcc_multi_sysroot;
|
|
||||||
};
|
|
||||||
} ''
|
|
||||||
mkdir -p $out/lib{,64}/gcc
|
|
||||||
|
|
||||||
ln -s ${combine gcc64}/lib/gcc/* $out/lib64/gcc/
|
|
||||||
ln -s ${combine gcc32}/lib/gcc/* $out/lib/gcc/
|
|
||||||
# XXX: This shouldn't be needed, clang just doesn't look for "i686-unknown"
|
|
||||||
ln -s $out/lib/gcc/i686-unknown-linux-gnu $out/lib/gcc/i686-pc-linux-gnu
|
|
||||||
|
|
||||||
|
|
||||||
# includes
|
|
||||||
mkdir -p $out/include
|
|
||||||
ln -s ${glibc_multi.dev}/include/* $out/include
|
|
||||||
ln -s ${gcc64.cc}/include/c++ $out/include/c++
|
|
||||||
|
|
||||||
# dynamic linkers
|
|
||||||
mkdir -p $out/lib/32
|
|
||||||
ln -s ${glibc_multi.out}/lib/ld-linux* $out/lib
|
|
||||||
ln -s ${glibc_multi.out}/lib/32/ld-linux* $out/lib/32/
|
|
||||||
'';
|
|
||||||
|
|
||||||
clangMulti = clang.override {
|
|
||||||
# Only used for providing expected structure re:dynamic linkers, AFAIK Most
|
|
||||||
# of the magic is done by setting the --gcc-toolchain option via
|
|
||||||
# `gccForLibs`.
|
|
||||||
libc = gcc_multi_sysroot;
|
|
||||||
|
|
||||||
bintools = clang.bintools.override {
|
|
||||||
libc = gcc_multi_sysroot;
|
|
||||||
};
|
|
||||||
|
|
||||||
gccForLibs = gcc_multi_sysroot // {
|
|
||||||
inherit (glibc_multi) libgcc;
|
|
||||||
langCC =
|
|
||||||
assert (gcc64.cc.langCC != gcc32.cc.langCC)
|
|
||||||
-> throw "(gcc64.cc.langCC=${gcc64.cc.langCC}) != (gcc32.cc.langCC=${gcc32.cc.langCC})";
|
|
||||||
gcc64.cc.langCC;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
in clangMulti
|
|
|
@ -3,7 +3,7 @@ name = "szl"
|
||||||
description = "Simple Zynq Loader"
|
description = "Simple Zynq Loader"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["M-Labs"]
|
authors = ["M-Labs"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
target_zc706 = ["libboard_zynq/target_zc706", "libsupport_zynq/target_zc706", "libconfig/target_zc706"]
|
target_zc706 = ["libboard_zynq/target_zc706", "libsupport_zynq/target_zc706", "libconfig/target_zc706"]
|
||||||
|
@ -16,10 +16,15 @@ default = ["target_zc706"]
|
||||||
[dependencies]
|
[dependencies]
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
byteorder = { version = "1.3", default-features = false }
|
byteorder = { version = "1.3", default-features = false }
|
||||||
core_io = { version = "0.1", features = ["collections"] }
|
|
||||||
|
|
||||||
libboard_zynq = { path = "../libboard_zynq" }
|
libboard_zynq = { path = "../libboard_zynq" }
|
||||||
libsupport_zynq = { path = "../libsupport_zynq" }
|
libsupport_zynq = { path = "../libsupport_zynq" }
|
||||||
libcortex_a9 = { path = "../libcortex_a9" }
|
libcortex_a9 = { path = "../libcortex_a9" }
|
||||||
libregister = { path = "../libregister" }
|
libregister = { path = "../libregister" }
|
||||||
libconfig = { path = "../libconfig" }
|
libconfig = { path = "../libconfig" }
|
||||||
|
|
||||||
|
[dependencies.fatfs]
|
||||||
|
git = "https://github.com/rafalh/rust-fatfs"
|
||||||
|
rev = "85f06e0"
|
||||||
|
default-features = false
|
||||||
|
features = ["alloc", "lfn"]
|
||||||
|
|
|
@ -8,7 +8,6 @@ mod netboot;
|
||||||
|
|
||||||
use alloc::rc::Rc;
|
use alloc::rc::Rc;
|
||||||
use core::mem;
|
use core::mem;
|
||||||
use core_io::{Read, Seek};
|
|
||||||
use libboard_zynq::{
|
use libboard_zynq::{
|
||||||
self as zynq,
|
self as zynq,
|
||||||
clocks::source::{ArmPll, ClockSource, IoPll},
|
clocks::source::{ArmPll, ClockSource, IoPll},
|
||||||
|
@ -16,7 +15,7 @@ use libboard_zynq::{
|
||||||
logger, println, sdio, slcr,
|
logger, println, sdio, slcr,
|
||||||
timer::GlobalTimer,
|
timer::GlobalTimer,
|
||||||
};
|
};
|
||||||
use libconfig::{bootgen, sd_reader, Config};
|
use libconfig::{bootgen, sd_reader, Config, File};
|
||||||
use libcortex_a9::{
|
use libcortex_a9::{
|
||||||
asm::{dsb, isb},
|
asm::{dsb, isb},
|
||||||
cache::{bpiall, dcciall, iciallu},
|
cache::{bpiall, dcciall, iciallu},
|
||||||
|
@ -30,8 +29,8 @@ extern "C" {
|
||||||
static mut __runtime_end: usize;
|
static mut __runtime_end: usize;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn boot_sd<File: Read + Seek>(
|
fn boot_sd<'a>(
|
||||||
file: &mut Option<File>,
|
file: &mut Option<File<'a>>,
|
||||||
runtime_start: *mut u8,
|
runtime_start: *mut u8,
|
||||||
runtime_max: usize,
|
runtime_max: usize,
|
||||||
) -> Result<(), ()> {
|
) -> Result<(), ()> {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use alloc::vec;
|
use alloc::vec;
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
use byteorder::{ByteOrder, NetworkEndian};
|
use byteorder::{ByteOrder, NetworkEndian};
|
||||||
use core_io::{Read, Seek};
|
|
||||||
use libboard_zynq::{
|
use libboard_zynq::{
|
||||||
devc,
|
devc,
|
||||||
eth::Eth,
|
eth::Eth,
|
||||||
|
@ -13,7 +12,7 @@ use libboard_zynq::{
|
||||||
},
|
},
|
||||||
timer::GlobalTimer,
|
timer::GlobalTimer,
|
||||||
};
|
};
|
||||||
use libconfig::{bootgen, net_settings, Config};
|
use libconfig::{bootgen, net_settings, Config, File};
|
||||||
|
|
||||||
enum NetConnState {
|
enum NetConnState {
|
||||||
WaitCommand,
|
WaitCommand,
|
||||||
|
@ -48,7 +47,7 @@ impl NetConn {
|
||||||
self.gateware_downloaded = false;
|
self.gateware_downloaded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn input_partial<File: Read + Seek>(
|
fn input_partial(
|
||||||
&mut self,
|
&mut self,
|
||||||
bootgen_file: &mut Option<File>,
|
bootgen_file: &mut Option<File>,
|
||||||
runtime_start: *mut u8,
|
runtime_start: *mut u8,
|
||||||
|
@ -284,9 +283,9 @@ impl NetConn {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn input<File: Read + Seek>(
|
fn input<'a>(
|
||||||
&mut self,
|
&mut self,
|
||||||
bootgen_file: &mut Option<File>,
|
bootgen_file: &mut Option<File<'a>>,
|
||||||
runtime_start: *mut u8,
|
runtime_start: *mut u8,
|
||||||
runtime_max_len: usize,
|
runtime_max_len: usize,
|
||||||
buf: &[u8],
|
buf: &[u8],
|
||||||
|
@ -309,8 +308,8 @@ impl NetConn {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn netboot<File: Read + Seek>(
|
pub fn netboot<'a>(
|
||||||
bootgen_file: &mut Option<File>,
|
bootgen_file: &mut Option<File<'a>>,
|
||||||
cfg: Config,
|
cfg: Config,
|
||||||
runtime_start: *mut u8,
|
runtime_start: *mut u8,
|
||||||
runtime_max_len: usize,
|
runtime_max_len: usize,
|
||||||
|
|
Loading…
Reference in New Issue