{"id":1344,"date":"2020-01-22T14:44:54","date_gmt":"2020-01-22T12:44:54","guid":{"rendered":"http:\/\/blog.the-leviathan.ch\/?p=1344"},"modified":"2020-01-22T15:16:38","modified_gmt":"2020-01-22T13:16:38","slug":"cross-compiler-for-z-os","status":"publish","type":"post","link":"https:\/\/blog.the-leviathan.ch\/?p=1344","title":{"rendered":"Cross compiler for z\/oS"},"content":{"rendered":"\n<p>Go here: <a href=\"http:\/\/45.76.81.249\/zOS\/\">http:\/\/45.76.81.249\/zOS<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">~.bashrc<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>export PATH=\/opt\/IBM\/bin:$PATH\nexport CFLAGS=\"$CFLAGS -Wno-error\"<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Folders<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir PEP_ZOS\nsudo mkdir -p \/opt\/IBM\nsudo chown `whoami`:users -R \/opt\/IBM<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Repositories<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>cd PEP_ZOS<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone https:\/\/git.kernel.org\/pub\/scm\/linux\/kernel\/git\/stable\/linux.git\ncd linux\ngit checkout v5.3.12\ncd ..<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/leviathanch\/binutils.git\ncd binutils\ngit checkout lev\/master<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/leviathanch\/gcc.git\ncd gcc\ngit checkout lev\/master\ncd ..<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>got clone https:\/\/github.com\/leviathanch\/glibc.git\ncd glibc\ngit checkout lev\/master\ncd ..<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Building steps<\/h2>\n\n\n\n<p>First we need to build the binutils with patches to generate and link bytecode recognized by the z\/OS environment.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd binutils\/build\n\n..\/configure --prefix=\/opt\/IBM --program-prefix=s390x-ibm-zos-gnu- --target=s390x-ibm-zos-gnu\n\nmake -j4\n\nmake install\n\ncd ..\/..<\/code><\/pre>\n\n\n\n<p>Now we need to provide the kernel headers, since this is a requirement for building gcc and glibc (even if z\/OS isn&#8217;t a Linux)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd linux\n\nmake ARCH=s390 menuconfig (got to exit and save)\n\nmake ARCH=s390 INSTALL_HDR_PATH=\/opt\/IBM\/s390x-ibm-zos-gnu headers_install\n\ncd ..<\/code><\/pre>\n\n\n\n<p>Now we build the first stage of the gcc bootstrap phase<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd gcc\/build\n\n..\/configure --prefix=\/opt\/IBM --program-prefix=s390x-ibm-zos-gnu- --target=s390x-ibm-zos-gnu --disable-multilib --enable-languages=c,c++ --disable-shared --disable-checking\n\nmake -j4 all-gcc\n\nmake install-gcc\n\ncd ..\/..<\/code><\/pre>\n\n\n\n<p>Now we build the GLIBC on which the rest of GCC depends<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd glibc\/build\n\nexport CFLAGS=\"-Wno-error -I\/opt\/IBM\/include -L\/opt\/IBM\/lib64\/gcc\/s390x-ibm-zos-gnu\/8.3.1 -I\/opt\/IBM\/lib64\/gcc\/s390x-ibm-zos-gnu\/8.3.1\/include -static -fsplit-stack -O3 -fexec-charset=IBM-1047\"\n\n..\/configure --prefix=\/opt\/IBM\/s390x-ibm-zos-gnu --host=s390x-ibm-zos-gnu --target=s390x-ibm-zos-gnu --build=s390x-ibm-zos-gnu --disable-multilib --with-headers=\/opt\/IBM\/s390x-ibm-zos-gnu\/include --disable-shared --disable-nscd\n\nmake install-bootstrap-headers=yes install-headers\n\nmake -j4 csu\/subdir_lib\n\ninstall csu\/*.o \/opt\/IBM\/s390x-ibm-zos-gnu\/lib\/\n\ntouch \/opt\/IBM\/s390x-ibm-zos-gnu\/include\/gnu\/stubs.h\n\ns390x-ibm-zos-gnu-gcc -nostdlib -nostartfiles -shared -x c \/dev\/null -o \/opt\/IBM\/s390x-ibm-zos-gnu\/lib\/libc.so\n\ncd ..\/..<\/code><\/pre>\n\n\n\n<p>Now we&#8217;ve got to build libgcc<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd gcc\/build\n\nmake -j4 all-target-libgcc\n\nmake install-target-libgcc\n\ncd ..\/..<\/code><\/pre>\n\n\n\n<p>Now we&#8217;ve got to finalize the GLIBC build<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd glibc\/build\n\nmake -j4\n\nmake install\n\ncd ..\/..<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Go here: http:\/\/45.76.81.249\/zOS ~.bashrc Folders Repositories Building steps First we need to build the binutils with patches to generate and link bytecode recognized by the z\/OS environment. Now we need to provide the kernel headers, since this is a requirement for building gcc and glibc (even if z\/OS isn&#8217;t a Linux) Now we build the &hellip; <a href=\"https:\/\/blog.the-leviathan.ch\/?p=1344\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Cross compiler for z\/oS<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1344","post","type-post","status-publish","format-standard","hentry","category-daily"],"_links":{"self":[{"href":"https:\/\/blog.the-leviathan.ch\/index.php?rest_route=\/wp\/v2\/posts\/1344","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.the-leviathan.ch\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.the-leviathan.ch\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.the-leviathan.ch\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.the-leviathan.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1344"}],"version-history":[{"count":38,"href":"https:\/\/blog.the-leviathan.ch\/index.php?rest_route=\/wp\/v2\/posts\/1344\/revisions"}],"predecessor-version":[{"id":1468,"href":"https:\/\/blog.the-leviathan.ch\/index.php?rest_route=\/wp\/v2\/posts\/1344\/revisions\/1468"}],"wp:attachment":[{"href":"https:\/\/blog.the-leviathan.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1344"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.the-leviathan.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1344"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.the-leviathan.ch\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1344"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}