Merge branch 'trunk' into morphic-lib

This commit is contained in:
Richard Feldman 2021-05-24 07:18:59 -04:00 committed by GitHub
commit b60988d63e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 75 additions and 51 deletions

25
Cargo.lock generated
View file

@ -2128,22 +2128,21 @@ dependencies = [
[[package]] [[package]]
name = "object" name = "object"
version = "0.22.0" version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4"
[[package]]
name = "object"
version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a5b3dd1c072ee7963717671d1ca129f1048fda25edea6b752bfc71ac8854170"
dependencies = [ dependencies = [
"crc32fast", "crc32fast",
"flate2", "flate2",
"indexmap", "indexmap",
"wasmparser",
] ]
[[package]]
name = "object"
version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4"
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.7.2" version = "1.7.2"
@ -3185,7 +3184,7 @@ dependencies = [
"libc", "libc",
"libloading 0.6.7", "libloading 0.6.7",
"maplit", "maplit",
"object 0.22.0", "object 0.24.0",
"pretty_assertions 0.5.1", "pretty_assertions 0.5.1",
"quickcheck 0.8.5", "quickcheck 0.8.5",
"quickcheck_macros 0.8.0", "quickcheck_macros 0.8.0",
@ -4199,12 +4198,6 @@ version = "0.2.74"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7cff876b8f18eed75a66cf49b65e7f967cb354a7aa16003fb55dbfd25b44b4f" checksum = "d7cff876b8f18eed75a66cf49b65e7f967cb354a7aa16003fb55dbfd25b44b4f"
[[package]]
name = "wasmparser"
version = "0.57.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32fddd575d477c6e9702484139cf9f23dcd554b06d185ed0f56c857dd3a47aa6"
[[package]] [[package]]
name = "wayland-client" name = "wayland-client"
version = "0.28.5" version = "0.28.5"

View file

@ -1,4 +1,4 @@
#![warn(clippy::all, clippy::dbg_macro)] #![warn(clippy::dbg_macro)]
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check. // See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
#![allow(clippy::large_enum_variant)] #![allow(clippy::large_enum_variant)]
pub mod link; pub mod link;

View file

@ -1,4 +1,4 @@
#![warn(clippy::all, clippy::dbg_macro)] #![warn(clippy::dbg_macro)]
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check. // See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
#![allow(clippy::large_enum_variant)] #![allow(clippy::large_enum_variant)]
pub mod bitcode; pub mod bitcode;

View file

@ -1,4 +1,4 @@
#![warn(clippy::all, clippy::dbg_macro)] #![warn(clippy::dbg_macro)]
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check. // See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
#![allow(clippy::large_enum_variant)] #![allow(clippy::large_enum_variant)]
pub mod annotation; pub mod annotation;

View file

@ -1,4 +1,4 @@
#![warn(clippy::all, clippy::dbg_macro)] #![warn(clippy::dbg_macro)]
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check. // See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
#![allow(clippy::large_enum_variant)] #![allow(clippy::large_enum_variant)]

View file

@ -1,4 +1,4 @@
#![warn(clippy::all, clippy::dbg_macro)] #![warn(clippy::dbg_macro)]
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check. // See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
#![allow(clippy::large_enum_variant)] #![allow(clippy::large_enum_variant)]
pub mod builtins; pub mod builtins;

View file

@ -1,4 +1,4 @@
#![warn(clippy::all, clippy::dbg_macro)] #![warn(clippy::dbg_macro)]
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check. // See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
#![allow(clippy::large_enum_variant)] #![allow(clippy::large_enum_variant)]
pub mod annotation; pub mod annotation;

View file

@ -1,4 +1,4 @@
#![warn(clippy::all, clippy::dbg_macro)] #![warn(clippy::dbg_macro)]
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check. // See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
#![allow(clippy::large_enum_variant)] #![allow(clippy::large_enum_variant)]
// we actually want to compare against the literal float bits // we actually want to compare against the literal float bits

View file

@ -23,7 +23,7 @@ bumpalo = { version = "3.6.1", features = ["collections"] }
inlinable_string = "0.1" inlinable_string = "0.1"
target-lexicon = "0.10" target-lexicon = "0.10"
libloading = "0.6" libloading = "0.6"
object = { version = "0.22", features = ["write"] } object = { version = "0.24", features = ["write"] }
[dev-dependencies] [dev-dependencies]
roc_can = { path = "../can" } roc_can = { path = "../can" }

View file

@ -1,4 +1,4 @@
#![warn(clippy::all, clippy::dbg_macro)] #![warn(clippy::dbg_macro)]
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check. // See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
#![allow(clippy::large_enum_variant, clippy::upper_case_acronyms)] #![allow(clippy::large_enum_variant, clippy::upper_case_acronyms)]

View file

@ -13,7 +13,9 @@ use roc_mono::ir::Proc;
use roc_mono::layout::Layout; use roc_mono::layout::Layout;
use target_lexicon::{Architecture as TargetArch, BinaryFormat as TargetBF, Triple}; use target_lexicon::{Architecture as TargetArch, BinaryFormat as TargetBF, Triple};
const VERSION: &str = env!("CARGO_PKG_VERSION"); // This is used by some code below which is currently commented out.
// See that code for more details!
// const VERSION: &str = env!("CARGO_PKG_VERSION");
/// build_module is the high level builder/delegator. /// build_module is the high level builder/delegator.
/// It takes the request to build a module and output the object file for the module. /// It takes the request to build a module and output the object file for the module.
@ -41,6 +43,28 @@ pub fn build_module<'a>(
Object::new(BinaryFormat::Elf, Architecture::X86_64, Endianness::Little), Object::new(BinaryFormat::Elf, Architecture::X86_64, Endianness::Little),
) )
} }
Triple {
architecture: TargetArch::X86_64,
binary_format: TargetBF::Macho,
..
} => {
let backend: Backend64Bit<
x86_64::X86_64GeneralReg,
x86_64::X86_64FloatReg,
x86_64::X86_64Assembler,
x86_64::X86_64SystemV,
> = Backend::new(env, target)?;
build_object(
env,
procedures,
backend,
Object::new(
BinaryFormat::MachO,
Architecture::X86_64,
Endianness::Little,
),
)
}
Triple { Triple {
architecture: TargetArch::Aarch64(_), architecture: TargetArch::Aarch64(_),
binary_format: TargetBF::Elf, binary_format: TargetBF::Elf,
@ -72,12 +96,16 @@ fn build_object<'a, B: Backend<'a>>(
mut output: Object, mut output: Object,
) -> Result<Object, String> { ) -> Result<Object, String> {
let data_section = output.section_id(StandardSection::Data); let data_section = output.section_id(StandardSection::Data);
let comment = output.add_section(vec![], b"comment".to_vec(), SectionKind::OtherString);
/*
// Commented out because we couldn't figure out how to get it to work on mac - see https://github.com/rtfeldman/roc/pull/1323
let comment = output.add_section(vec![], b".comment".to_vec(), SectionKind::OtherString);
output.append_section_data( output.append_section_data(
comment, comment,
format!("\0roc dev backend version {} \0", VERSION).as_bytes(), format!("\0roc dev backend version {} \0", VERSION).as_bytes(),
1, 1,
); );
*/
// Setup layout_ids for procedure calls. // Setup layout_ids for procedure calls.
let mut layout_ids = roc_mono::layout::LayoutIds::default(); let mut layout_ids = roc_mono::layout::LayoutIds::default();
@ -89,7 +117,7 @@ fn build_object<'a, B: Backend<'a>>(
let section_id = output.add_section( let section_id = output.add_section(
output.segment_name(StandardSegment::Text).to_vec(), output.segment_name(StandardSegment::Text).to_vec(),
format!(".text.{}", fn_name).as_bytes().to_vec(), format!(".text.{:x}", sym.as_u64()).as_bytes().to_vec(),
SectionKind::Text, SectionKind::Text,
); );
@ -182,7 +210,7 @@ fn build_object<'a, B: Backend<'a>>(
offset: offset + proc_offset, offset: offset + proc_offset,
size: 32, size: 32,
kind: RelocationKind::PltRelative, kind: RelocationKind::PltRelative,
encoding: RelocationEncoding::Generic, encoding: RelocationEncoding::X86Branch,
symbol: sym_id, symbol: sym_id,
addend: -4, addend: -4,
} }

View file

@ -10,7 +10,7 @@ extern crate libc;
#[macro_use] #[macro_use]
mod helpers; mod helpers;
#[cfg(all(test, target_os = "linux", any(target_arch = "x86_64"/*, target_arch = "aarch64"*/)))] #[cfg(all(test, any(target_os = "linux", target_os = "macos"), any(target_arch = "x86_64"/*, target_arch = "aarch64"*/)))]
mod gen_num { mod gen_num {
#[test] #[test]
fn i64_values() { fn i64_values() {

View file

@ -51,7 +51,7 @@ const DEFAULT_APP_OUTPUT_PATH: &str = "app";
const ROC_FILE_EXTENSION: &str = "roc"; const ROC_FILE_EXTENSION: &str = "roc";
/// Roc-Config file name /// Roc-Config file name
const PKG_CONFIG_FILE_NAME: &str = "Pkg-Config"; const PKG_CONFIG_FILE_NAME: &str = "Package-Config";
/// The . in between module names like Foo.Bar.Baz /// The . in between module names like Foo.Bar.Baz
const MODULE_SEPARATOR: char = '.'; const MODULE_SEPARATOR: char = '.';
@ -1892,7 +1892,7 @@ fn update<'a>(
let work = state.dependencies.notify(module_id, Phase::SolveTypes); let work = state.dependencies.notify(module_id, Phase::SolveTypes);
// if there is a platform, the Pkg-Config module provides host-exposed, // if there is a platform, the Package-Config module provides host-exposed,
// otherwise the App module exposes host-exposed // otherwise the App module exposes host-exposed
let is_host_exposed = match state.platform_id { let is_host_exposed = match state.platform_id {
None => module_id == state.root_id, None => module_id == state.root_id,
@ -2320,7 +2320,7 @@ fn load_pkg_config<'a>(
let chomped = &bytes[..delta]; let chomped = &bytes[..delta];
let header_src = unsafe { std::str::from_utf8_unchecked(chomped) }; let header_src = unsafe { std::str::from_utf8_unchecked(chomped) };
// make a Pkg-Config module that ultimately exposes `main` to the host // make a Package-Config module that ultimately exposes `main` to the host
let pkg_config_module_msg = fabricate_pkg_config_module( let pkg_config_module_msg = fabricate_pkg_config_module(
arena, arena,
shorthand, shorthand,
@ -2559,7 +2559,7 @@ fn parse_header<'a>(
}) => { }) => {
match package_or_path { match package_or_path {
PackageOrPath::Path(StrLiteral::PlainLine(package)) => { PackageOrPath::Path(StrLiteral::PlainLine(package)) => {
// check whether we can find a Pkg-Config.roc file // check whether we can find a Package-Config.roc file
let mut pkg_config_roc = pkg_config_dir; let mut pkg_config_roc = pkg_config_dir;
pkg_config_roc.push(package); pkg_config_roc.push(package);
pkg_config_roc.push(PKG_CONFIG_FILE_NAME); pkg_config_roc.push(PKG_CONFIG_FILE_NAME);

View file

@ -1,4 +1,4 @@
#![warn(clippy::all, clippy::dbg_macro)] #![warn(clippy::dbg_macro)]
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check. // See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
#![allow(clippy::large_enum_variant)] #![allow(clippy::large_enum_variant)]
pub mod docs; pub mod docs;

View file

@ -1,4 +1,4 @@
#![warn(clippy::all, clippy::dbg_macro)] #![warn(clippy::dbg_macro)]
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check. // See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
#![allow(clippy::large_enum_variant, clippy::upper_case_acronyms)] #![allow(clippy::large_enum_variant, clippy::upper_case_acronyms)]

View file

@ -86,6 +86,10 @@ impl Symbol {
}) })
} }
pub fn as_u64(self) -> u64 {
self.0
}
pub fn fully_qualified(self, interns: &Interns, home: ModuleId) -> InlinableString { pub fn fully_qualified(self, interns: &Interns, home: ModuleId) -> InlinableString {
let module_id = self.module_id(); let module_id = self.module_id();

View file

@ -1,4 +1,4 @@
#![warn(clippy::all, clippy::dbg_macro)] #![warn(clippy::dbg_macro)]
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check. // See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
#![allow(clippy::large_enum_variant, clippy::upper_case_acronyms)] #![allow(clippy::large_enum_variant, clippy::upper_case_acronyms)]

View file

@ -1,4 +1,4 @@
#![warn(clippy::all, clippy::dbg_macro)] #![warn(clippy::dbg_macro)]
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check. // See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
#![allow(clippy::large_enum_variant)] #![allow(clippy::large_enum_variant)]

View file

@ -1,4 +1,4 @@
#![warn(clippy::all, clippy::dbg_macro)] #![warn(clippy::dbg_macro)]
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check. // See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
#![allow(clippy::large_enum_variant)] #![allow(clippy::large_enum_variant)]
pub mod can; pub mod can;

View file

@ -1,4 +1,4 @@
#![warn(clippy::all, clippy::dbg_macro)] #![warn(clippy::dbg_macro)]
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check. // See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
#![allow(clippy::large_enum_variant)] #![allow(clippy::large_enum_variant)]

View file

@ -1,4 +1,4 @@
#![warn(clippy::all, clippy::dbg_macro)] #![warn(clippy::dbg_macro)]
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check. // See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
#![allow(clippy::large_enum_variant)] #![allow(clippy::large_enum_variant)]

View file

@ -1,4 +1,4 @@
#![warn(clippy::all, clippy::dbg_macro)] #![warn(clippy::dbg_macro)]
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check. // See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
#![allow(clippy::large_enum_variant)] #![allow(clippy::large_enum_variant)]

View file

@ -1,4 +1,4 @@
#![warn(clippy::all, clippy::dbg_macro)] #![warn(clippy::dbg_macro)]
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check. // See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
#![allow(clippy::large_enum_variant)] #![allow(clippy::large_enum_variant)]
// we actually want to compare against the literal float bits // we actually want to compare against the literal float bits

View file

@ -1,4 +1,4 @@
#![warn(clippy::all, clippy::dbg_macro)] #![warn(clippy::dbg_macro)]
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check. // See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
#![allow(clippy::large_enum_variant)] #![allow(clippy::large_enum_variant)]
pub mod builtin_aliases; pub mod builtin_aliases;

View file

@ -1,4 +1,4 @@
#![warn(clippy::all, clippy::dbg_macro)] #![warn(clippy::dbg_macro)]
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check. // See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
#![allow(clippy::large_enum_variant)] #![allow(clippy::large_enum_variant)]

View file

@ -1,4 +1,4 @@
#![warn(clippy::all, clippy::dbg_macro)] #![warn(clippy::dbg_macro)]
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check. // See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
#![allow(clippy::large_enum_variant, clippy::upper_case_acronyms)] #![allow(clippy::large_enum_variant, clippy::upper_case_acronyms)]

View file

@ -13,4 +13,3 @@ platform examples/shared-quicksort
mainForHost : List I64 -> List I64 mainForHost : List I64 -> List I64
mainForHost = \list -> quicksort list mainForHost = \list -> quicksort list