Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable plan 9 as a valid compiler target #19389

Merged
merged 5 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions vlib/os/os.v
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ pub fn user_os() string {
$if serenity {
return 'serenity'
}
//$if plan9 {
// return 'plan9'
//}
$if vinix {
return 'vinix'
}
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/ast/comptime_valid_idents.v
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module ast
pub const (
valid_comptime_if_os = ['windows', 'ios', 'macos', 'mach', 'darwin', 'hpux', 'gnu',
'qnx', 'linux', 'freebsd', 'openbsd', 'netbsd', 'bsd', 'dragonfly', 'android', 'termux',
'solaris', 'haiku', 'serenity', 'vinix']
'solaris', 'haiku', 'serenity', 'vinix', 'plan9']
valid_comptime_if_compilers = ['gcc', 'tinyc', 'clang', 'mingw', 'msvc', 'cplusplus']
valid_comptime_if_platforms = ['amd64', 'i386', 'aarch64', 'arm64', 'arm32', 'rv64', 'rv32']
valid_comptime_if_cpu_features = ['x64', 'x32', 'little_endian', 'big_endian']
Expand Down
2 changes: 2 additions & 0 deletions vlib/v/doc/doc.v
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub enum Platform {
termux // like android, but note that termux is running on devices natively, not cross compiling from other platforms
solaris
serenity
plan9
vinix
haiku
raw
Expand All @@ -63,6 +64,7 @@ pub fn platform_from_string(platform_str string) !Platform {
'js' { return .js }
'solaris' { return .solaris }
'serenity' { return .serenity }
'plan9' {return .plan9}
'vinix' { return .vinix }
'android' { return .android }
'termux' { return .termux }
Expand Down
9 changes: 7 additions & 2 deletions vlib/v/gen/c/cheaders.v
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,10 @@ const c_common_macros = '
#else
// On linux: int backtrace(void **__array, int __size);
// On BSD: size_t backtrace(void **, size_t);
#endif
#endif
#endif
#endif

#ifdef __TINYC__
#define _Atomic volatile
#undef EMPTY_STRUCT_DECLARATION
Expand Down Expand Up @@ -558,6 +558,11 @@ voidptr memdup(voidptr src, int sz);
#include <sys/wait.h> // os__wait uses wait on nix
#endif

#if defined(__plan9__)
#include <u.h>
#include <libc.h>
#endif

#ifdef __OpenBSD__
#include <sys/types.h>
#include <sys/resource.h>
Expand Down
3 changes: 3 additions & 0 deletions vlib/v/gen/c/comptime.v
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,9 @@ fn (mut g Gen) comptime_if_to_ifdef(name string, is_comptime_option bool) !strin
'serenity' {
return '__serenity__'
}
'plan9' {
return '__plan9__'
}
'vinix' {
return '__vinix__'
}
Expand Down
3 changes: 3 additions & 0 deletions vlib/v/gen/native/comptime.v
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ fn (mut g Gen) comptime_ident(name string, is_comptime_option bool) bool {
'serenity' {
g.pref.os == .serenity
}
'plan9' {
g.pref.os == .plan9
}
'vinix' {
g.pref.os == .vinix
}
Expand Down
3 changes: 2 additions & 1 deletion vlib/v/help/build/build-c.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ see also `v help build`.
`android`, `termux`,
`freebsd`, `openbsd`, `netbsd`, `dragonfly`,
`solaris`, `serenity`, `haiku`,
`plan9`,
`wasm32`, `wasm32-wasi`, `wasm32-emscripten`

Note that V has the concept of platform files, i.e. files ending
Expand Down Expand Up @@ -325,4 +326,4 @@ see also `v help build`.
https://learn.microsoft.com/en-us/cpp/build/reference/fp-specify-floating-point-behavior?view=msvc-170&redirectedfrom=MSDN
https://clang.llvm.org/docs/UsersManual.html#cmdoption-ffast-math
https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-ffast-math

8 changes: 8 additions & 0 deletions vlib/v/pref/os.v
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub enum OS {
solaris
qnx
serenity
plan9
vinix
haiku
wasm32
Expand Down Expand Up @@ -85,6 +86,9 @@ pub fn os_from_string(os_str string) !OS {
'serenity' {
return .serenity
}
'plan9' {
return .plan9
}
'vinix' {
return .vinix
}
Expand Down Expand Up @@ -154,6 +158,7 @@ pub fn (o OS) str() string {
.solaris { return 'Solaris' }
.qnx { return 'QNX' }
.serenity { return 'SerenityOS' }
.plan9 { return 'Plan9'}
.vinix { return 'Vinix' }
.haiku { return 'Haiku' }
.wasm32 { return 'WebAssembly' }
Expand Down Expand Up @@ -207,6 +212,9 @@ pub fn get_host_os() OS {
$if serenity {
return .serenity
}
//$if plan9 {
// return .plan9
//}
$if vinix {
return .vinix
}
Expand Down
3 changes: 3 additions & 0 deletions vlib/v/pref/should_compile.v
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ pub fn (prefs &Preferences) should_compile_c(file string) bool {
if prefs.os != .serenity && file.ends_with('_serenity.c.v') {
return false
}
if prefs.os != .plan9 && file.ends_with('_plan9.c.v') {
return false
}
if prefs.os != .vinix && file.ends_with('_vinix.c.v') {
return false
}
Expand Down
2 changes: 0 additions & 2 deletions vlib/x/x.v
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module x

pub const description = 'an empty module, used as a placeholder, for other modules'
spytheman marked this conversation as resolved.
Show resolved Hide resolved