GithubHelp home page GithubHelp logo

bobsteagall / gcc-builder Goto Github PK

View Code? Open in Web Editor NEW
61.0 5.0 14.0 63 KB

A collection of scripts for building GCC on Linux

License: University of Illinois/NCSA Open Source License

Makefile 2.50% Shell 97.50%
gcc gcc6 gcc7 gcc8 gcc9 gcc10 gcc11 gcc12

gcc-builder's Introduction

================================================================================
 2022-08-05
 Bob Steagall
 KEWB Computing
================================================================================
This is the README file for the KEWB GCC 12.X.0 build scripts.  In the following
text, the version numbers will be referred to as 12.X.0 or 12X0, depending on
the usage and context.  The 'X' refers to GCC's minor version number; e.g., if
'X' is '2', then you intend to build, install, and use GCC 12.2.0.

In order to run these scripts, the following prerequisites must be installed:
 a. lsb_release on Linux
 b. the typical GNU software development and build tools

--------------------------------------------
1. SCRIPTS THAT PROVIDE CUSTOM BUILD OPTIONS

  * gcc-build-vars.sh - This very important script sets critical environment
    variables that are used by all the other scripts.  The first few variables
    can be modified; if you think you want to modify some of these variables,
    follow the directions in the script file.


----------------------------------------------------
2. TOP-LEVEL SCRIPTS THAT PERFORM HIGH-LEVEL ACTIONS

  * build-gcc.sh - This script will perform an entire build of GCC.  It does
    so by running fetch-gcc.sh, unpack-gcc.sh, configure-gcc.sh, make-gcc.sh,
    and the test scripts, in that order.

  * stage-gcc.sh - This script installs GCC into a staging location specified
    by the build variables script (gcc-build-vars.sh).  This is normally in
    the ./dist subdirectory, which serves as the staging area for creating a
    TGZ (compressed tarball) file and/or an RPM file.

  * pack-gcc.sh - This script creates a compressed tarball of compiler files
    installed into the staging directory by the stage-gcc.sh script.  The
    resulting TGZ file will be in the ./packages subdirectory.

  * install-gcc-tarball.sh - This script unpacks the TGZ file created by the
    packing script (pack-gcc.sh) into the directory structure specified in
    the build variables script (gcc-build-vars.sh).

  * make-gcc-rpm.sh - This script creates an RPM of the compiler files
    installed into the staging directory by the stage-gcc.sh script.  The
    resulting RPM file will be in the ./packages subdirectory.


-----------------------------------------------------
3. SECOND-LEVEL SCRIPTS THAT PERFORM BASIC OPERATIONS

This set of scripts performs several basic operations that are part of the
build process.  Each operation is a distinct step in that process.

  * fetch-gcc.sh - This script downloads the required source tarballs from
    GNU mirror sites

  * unpack-gcc.sh - This script unpacks the tarballs, places everything in
    the correct relative locations, and then performs any required patching.

  * configure-gcc.sh - This script runs GCC's configure script from within
    the build subdirectory.  It sets several key options for building GCC,
    including some that are specified by the environment variables set in
    gcc-build-vars.sh.

  * make-gcc.sh - This script makes GCC from within the build subdirectory.
    It runs with -j8 (i.e., up to 8 parallel processes); you can change this
    value by modifying the GCC_BUILD_THREADS_ARG variable defined in the
    gcc-build-vars.sh script described above.

  * clean-gcc.sh - This script deletes the source, build, install staging,
    and package output directories.


--------------------------------------------
4. HOW TO BUILD GCC 12.X.0 WITH THESE SCRIPTS

(NB: In the directions below, remember to replace the 'X' with the minor
version number!)


The process is pretty simple:

 a. Clone the git repo and checkout the gcc12 branch.

    $ cd <build_dir>
    $ git clone https://github.com/BobSteagall/gcc-builder.git
    $ cd <build_dir>/gcc-builder
    $ git checkout gcc12

 b. Customize the variables exported by gcc-build-vars.sh.  In particular,
    you will need to customize the first variable at the top of that file,
    GCC_VERSION, to select the specific version of GCC 12 to download and
    build.

    $ vi ./gcc-build-vars.sh

 c. Run the build-gcc.sh script.

    $ ./build-gcc.sh | tee build.log

    This command will build GCC and run the various test suites that come
    with the distribution.

    To build without running the test suites, you can use:

    $ ./build-gcc.sh -T | tee build.log

d. If the build succeeds, and you are satisfied with the test results, run
    the stage-gcc.sh script to create the installation staging area.

    $ ./stage-gcc.sh

 e. If you want to create a tarball for subsequent installations:

    $ ./pack-gcc.sh

    The resulting tarball will be in the ./packages subdirectory.  To install
    the tarball:

    $ sudo ./install-gcc-tarball.sh

    or, alternatively:

    $ sudo tar -zxvf ./gcc-builder/kewb-gcc12X0*.tgz -C /

    If you are satisfied that everything is working correctly, then at some
    point you may want to set ownership of the un-tarred files to root
    (substitute the values of GCC_INSTALL_PREFIX and GCC_INSTALL_SCRIPTS_PREFIX
    that you defined in gcc-build-vars.sh):

    $ sudo chown -R root:root $GCC_INSTALL_PREFIX
    $ sudo chown root:root $GCC_INSTALL_SCRIPTS_PREFIX/*gcc12X0*

 f. If you want to create an RPM for subsequent installations:

    $ ./make-gcc-rpm.sh -v

    The resulting RPM will be in the ./packages subdirectory.  Install it
    using RPM or YUM on the command line.

 g. That's it!

IMPORTANT WARNING:

If you want to rebuild GCC 12.X.0 after having built and installed it according
to these directions, AND you built with a custom binutils, AND you plan to
install the rebuilt version in the same location as its predecessor, then it
is imperative that you first perform exactly one of the following three actions:

  a. Delete the installation directory, for example:

    $ rm -rf /usr/local/gcc/12.X.0

  --OR--

  b. Rename the installation directory, for example:

    $ mv /usr/local/gcc/12.X.0 /usr/local/gcc/12.X-old

  --OR--

  c. Rename the custom 'as' and 'ld' exectuables, for example:

    $ cd /usr/local/gcc/12.X.0/libexec/gcc/x86_64-kewb-linux-gnu/12.X.0
    $ mv as as-old
    $ mv ld ld-old

Otherwise, the configure portion of the build process will find the custom
'as' and 'ld' executables in the GCC 12.X.0 directory structure, and build
the 'crtbeginS.o' startup file in a way that is likely to be incompatible
with your system's default linker.

It is _critical_ that the compilation of GCC itself takes place using your
system's default binutils, and not the custom 'as' and 'ld' that are
installed in the GCC 12.X.0 directory structure.


---------------------------------------------
5. HOW TO USE THE KEWB CUSTOM GCC 12.X.0 BUILD

Before using the compiler, some paths need to be set.  The simplest way to do
this is source the "setenv-for-gcc12X0.sh" script that is installed.

 a. Source the script /usr/local/bin/setenv-for-gcc-12X0.sh, which was installed
    in step 4.e or 4.f above.  For example,

        $ source /usr/local/bin/setenv-for-gcc12X0.sh

-- OR --

 a. You will need to modify your PATH environment variable so that the
    directory $GCC_INSTALL_DIR/bin appears before the directory where your
    system default compiler is installed (which is usually in /usr/bin or
    /usr/local/bin).  For example,

        $ export PATH=/usr/local/gcc/12.X.0/bin:$PATH

 b. You will also need to modify your LD_LIBRARY_PATH environment variable so
    that the $GCC_INSTALL_PREFIX/lib and $GCC_INSTALL_PREFIX/lib64 directories
    appear first in the path.  For example,

        $ export LD_LIBRARY_PATH=/usr/local/gcc/12.X.0/lib:\
          /usr/local/gcc/12.X.0/lib64:$LD_LIBRARY_PATH

gcc-builder's People

Contributors

bobsteagall avatar rbjeffer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gcc-builder's Issues

Can't build RPM for GCC9

This appears to affect both GCC8 and GCC9, looking at the code.

the gcc_install_scripts_prefix macro is not defined when executing make-gcc-rpm.sh

Processing files: kewb-gcc930-9.3.0-0.7.4.x86_64
error: File must begin with "/": %{gcc_install_scripts_prefix}/setenv-for-gcc930.sh
error: File must begin with "/": %{gcc_install_scripts_prefix}/restore-default-paths-gcc930.sh
error: File must begin with "/": %{gcc_install_scripts_prefix}/gcc930
error: File must begin with "/": %{gcc_install_scripts_prefix}/g++930


RPM build errors:
    File must begin with "/": %{gcc_install_scripts_prefix}/setenv-for-gcc930.sh
    File must begin with "/": %{gcc_install_scripts_prefix}/restore-default-paths-gcc930.sh
    File must begin with "/": %{gcc_install_scripts_prefix}/gcc930
    File must begin with "/": %{gcc_install_scripts_prefix}/g++930

Looking at the SPEC file in both GCC8 and GCC9 branches, it looks like the wrong macro name is being specified in the make-gcc-rpm.sh script :

function rpmcmd ()
{
    rpmbuild -bb $RPM_QUIET                                             \
    --define "build_root_dir $BO_ROOT_DIR"                              \
    --define "gcc_install_dir $GCC_INSTALL_PREFIX"                      \
    --define "gcc_install_reldir $GCC_INSTALL_RELDIR"                   \
    --define "gcc_install_scripts_dir $GCC_INSTALL_SCRIPTS_PREFIX"      \
    --define "gcc_install_scripts_reldir $GCC_INSTALL_SCRIPTS_RELDIR"   \
    --define "gcc_tag $GCC_TAG"                                         \
    --define "gcc_version $GCC_VERSION"                                 \
    --define "gcc_rpm_release $RPM_RELEASE"                             \
    --define "product_arch $PLATFORM_ARCH"                              \
    --define "product_os $PLATFORM_OS"                                  \
    --define "_topdir $WORK_DIR"                                        \
    --define "_tmppath $WORK_DIR/TMP"                                   \
    --define "_rpmdir $OUTPUT_DIR"                                      \
    --define "_build_name_fmt %%{NAME}-%%{RELEASE}.%%{ARCH}.rpm"        \
    $SPEC_FILE
}

After changing gcc_install_scripts_dir to gcc_install_scripts_prefix I am able to build RPM without issues.

would adding UNSET improve the 'portability' of the scripts?

On my system:

uname -a

Linux fatdog64-bd0 5.19.14 #1 SMP PREEMPT_DYNAMIC Thu Oct 6 02:08:05 AEST 2022 x86_64 Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz GenuineIntel GNU/Linux

I had to run:

unset LIBRARY_PATH CPATH C_INCLUDE_PATH PKG_CONFIG_PATH CPLUS_INCLUDE_PATH INCLUDE

before compliation succeeded.

[Thank you for your work here though- very useful.]

Confusing GCC_INSTALL_PREFIX

I have gcc-builder placed in /u2/pjppetteri/Installations/gcc-builder.

In gcc-build-vars.sh I set:

export GCC_INSTALL_PREFIX=/u2/pjppetteri/compilers/gcc/11.3.0

when trying to compile gcc-11.3.0 but somehow my gcc gets installed in to path:
/u2/pjppetteri/Installations/gcc-builder/dist/u2/pjppetteri/compilers/gcc/11.3.0

Is this intentional? Is the first '/' in GCC_INSTALL_PREFIX always removed and the GCC_INSTALL_PREFIX should be put relative to the path I execute the scripts from?

system-type script architecture misdetection

The make-gcc.sh and pack-gcc.sh scripts call system-type.sh in order to return information about the system. The result is stored in a bash array and tokenized based on $IFS. On distributions where lsb_type -si returns multiple space-separated words, this causes the platform name/architecture/description to be parsed incorrectly, which in turn causes make-gcc-rpm.sh to fail.

An example of a distribution where lsb_type -si returns multiple words is SuSE Linux Enterprise Server 11, on which lsb_type -si returns "SUSE LINUX"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.