Skip to content

Instantly share code, notes, and snippets.

@niw
Last active July 26, 2019 03:40
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save niw/17884c8e8ab83e16053f9f61da9cc7f3 to your computer and use it in GitHub Desktop.

Build V lang compiler

A patcg and how to build it from the V lang initial open source release files

Usage

Lie this. Asuume that the platform is macOS.

mkdir vlang
git clone https://github.com/vlang/v.git
cd v/compiler
curl -O 'https://vlang.io/v.c'
patch -p1 < v.c.patch
clang -w -o vc v.c
# This is needed.
mkdir /tmp/vlang
# Since $HOME/v will be used to find v file, pass a path to the parent.
env HOME=$(cd $(pwd)/../..; pwd) ./vc -o v .

Then, you will get compiler.

--- v.c 2019-06-22 12:05:11.000000000 -0700
+++ v.c.patch 2019-06-22 12:05:08.000000000 -0700
@@ -6459,7 +6459,7 @@
#endif
;
- return _STR("/var/tmp/vlang%.*s/", main__Version.len, main__Version.str);
+ return _STR("/tmp/vlang/");
}
int main(int argc, char **argv) {
init_consts();
@@ -7442,7 +7442,7 @@
tos2("string_builder.v"),
});
- string lang_dir = string_add(os__home_dir(), tos2("/code/v/"));
+ string lang_dir = string_add(os__home_dir(), tos2("/v/"));
string out_name_c =
string_add(string_all_after(out_name, tos2("/")), tos2(".c"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment