hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

platform.ha (1000B)


      1 // SPDX-License-Identifier: GPL-3.0-only
      2 // (c) Hare authors <https://harelang.org>
      3 
      4 export type platform = struct {
      5 	name: str,
      6 	// Do we always need to link with libc? (and use cc instead of ld)
      7 	need_libc: bool,
      8 	// Additional default flags for this platform.
      9 	default_flags: [NSTAGES][]str,
     10 };
     11 
     12 const platforms: [_]platform = [
     13 	platform {
     14 		name = "Linux",
     15 		...
     16 	},
     17 	platform {
     18 		name = "FreeBSD",
     19 		...
     20 	},
     21 	platform {
     22 		name = "OpenBSD",
     23 		need_libc = true,
     24 		default_flags = [
     25 			[],
     26 			[],
     27 			[],
     28 			[],
     29 			// IBT/BTI is a CPU feature that prevents ROP-attacks.
     30 			// Since this is enforced by default on OpenBSD but not
     31 			// implemented by QBE, we need to disable the
     32 			// enforcement.  ld.lld(1) can do this for us by
     33 			// creating a custom segment.
     34 			["-z", "nobtcfi"],
     35 		],
     36 	},
     37 ];
     38 
     39 export fn get_platform(name: str) (*platform | unknown_platform) = {
     40 	for (let platform &.. platforms) {
     41 		if (platform.name == name) {
     42 			return platform;
     43 		};
     44 	};
     45 	return name: unknown_platform;
     46 };