diff --git a/compiler/main.v b/compiler/main.v index a1931dc645..4d42e408df 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -29,7 +29,7 @@ fn vtmp_path() string { } const ( - SupportedPlatforms = ['windows', 'mac', 'linux'] + SupportedPlatforms = ['windows', 'mac', 'linux', 'freebsd'] TmpPath = vtmp_path() ) @@ -37,6 +37,7 @@ enum OS { mac linux windows + freebsd } enum Pass { @@ -597,7 +598,7 @@ mut args := '' a << '-x objective-c' } // Without these libs compilation will fail on Linux - if (v.os == .linux || os.user_os() == 'linux') && v.pref.build_mode != .build { + if (v.os == .linux || os.user_os() == 'linux' || v.os == .freebsd) && v.pref.build_mode != .build { a << '-lm -ldl -lpthread' } // Find clang executable @@ -892,12 +893,16 @@ fn new_v(args[]string) *V { $if windows { _os = .windows } + $if freebsd { + _os = .freebsd + } } else { switch target_os { case 'linux': _os = .linux case 'windows': _os = .windows case 'mac': _os = .mac + case 'freebsd': _os = .freebsd } } builtins := [ diff --git a/compiler/parser.v b/compiler/parser.v index 3452a6390c..744f80404b 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -2616,6 +2616,7 @@ fn os_name_to_ifdef(name string) string { case 'windows': return '_WIN32' case 'mac': return '__APPLE__' case 'linux': return '__linux__' + case 'freebsd': return '__FreeBSD__' } panic('bad os ifdef name "$name"') return '' diff --git a/vlib/os/os.v b/vlib/os/os.v index 76dd0acd05..2a49dee6e6 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -455,6 +455,9 @@ pub fn user_os() string { $if windows { return 'windows' } + $if freebsd { + return 'freebsd' + } return 'unknown' }