Forum Discussion

gwatcha's avatar
gwatcha
Icon for New Contributor rankNew Contributor
5 years ago

How to install older version of GCC compiler for HLS?

I'm following the intel® high level synthesis compiler getting started guide for the Linux version it states that GCC compiler must be version 4.4.7 and newer ones are not supported.

I'm running Manjaro, and have installed gcc 4.4.7, but i++ keeps using the previous version when including files, and I think that is why it is breaking when I make.

Here is an example output when I try to make the counter example.

```

included fle targets: test-x86-64, test-fpga, test-gpp, clean
i++ counter.cpp -march=x86-64 -o test-x86-64
In file included from counter.cpp:1:
In file included from /home/michael/Program/intelFPGA/19.1/hls/include/HLS/hls.h:11:
In file included from /home/michael/Program/intelFPGA/19.1/hls/include/HLS/hls_internal.h:5:
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/queue:62:
/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/bits/stl_function.h:424:10: error: use of
undeclared identifier '__UINTPTR_TYPE__'
return (__UINTPTR_TYPE__)__x > (__UINTPTR_TYPE__)__y;
^
/usr/lib/gcc/x86_64-pc

```

As you can see, it uses `/usr/lib/gcc/x64_64-pc-linux-gnu/10.1.0`, instead of `/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.7`.

I don't know how to get it to use the older version, I have put these two lines in my .bashrc but it still does not work:

```

export CC=gcc-4.4
export GXX_INCLUDE=/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.7/include/c++

```

Please help, I've been trying to set up this hls thing for about a day now, it's so frustrating

16 Replies

    • gwatcha's avatar
      gwatcha
      Icon for New Contributor rankNew Contributor

      I tried setting that option earlier but I believe it is only for the Pro version, and I am using the Lite version (version 19.1, installed via additional software tab on quartus install page).

    • gwatcha's avatar
      gwatcha
      Icon for New Contributor rankNew Contributor

      Hey Kenny, thanks for your help. I think I set the option, but it dosen't seem to do anything.

      I tried setting

      `HLS_CXX_FLAGS := -gcc-name=gcc-4.4.7 -gcc-toolchain=/lib/gcc/x86_64-pc-linux-gnu/4.4.7`

      in the Makefile for the counter example, and it accepted the option (it does not accept the option with --gcc-toolchain syntax), but I still get the same error message when I build it. The option also isn't listed under --help, so I think this may be a bug.

  • KennyT_altera's avatar
    KennyT_altera
    Icon for Super Contributor rankSuper Contributor

    This might be a bug for older version of Quartus. Can you try it with the latest release 20.1? I will file a bug to developer to check on this if it still happened on 20.1.

    Also, When I check again the export GCC environment, it should show on the Path itsefl.

    Example:

    # GCC Enviroment

    export GCC_ROOTDIR=/usr/local/gcc_version/bin

    export PATH=$GCC_ROOTDIR:$PATH

    export LD_LIBRARY_PATH=user/...

    https://www.intel.co.jp/content/dam/www/programmable/us/en/pdfs/literature/an/an918.pdf

    To check gcc version

    gcc --version

    • gwatcha's avatar
      gwatcha
      Icon for New Contributor rankNew Contributor

      I got it working, although in a sort of hackish way.

      After installing `gcc44` on manjaro. I altered the Makefile of the counter example to have this at the top:

      ```

      SOURCE_FILES := counter.cpp
      HLS_CXX_FLAGS :=
      CXXFLAGS := -I/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.7/include/c++ -I/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.7/include/c++/x86_64-pc-linux-gnu
      CXX := i++

      ```

      So you can see I include the 4.4.7 library directly.

      I also had to rename the `10.1.0` directory in /usr/lib/gcc/x86_64-pc-linux-gnu to `10.1.0_` so it wouldn't be able to find it and stop prioritizing it.

      ```

      [zen x86_64-pc-linux-gnu]# pwd
      /usr/lib/gcc/x86_64-pc-linux-gnu

      [zen x86_64-pc-linux-gnu]# ls
      10.1.0_ 4.4.7

      ```

      After that, the example compiles!

      • gwatcha's avatar
        gwatcha
        Icon for New Contributor rankNew Contributor

        I would try it with Quartus 20.1, but how do I install the HLS compiler for that version? I noticed that it is not under the additional software tab.

  • KennyT_altera's avatar
    KennyT_altera
    Icon for Super Contributor rankSuper Contributor

    Yes, you need the same compiler for HLS.

    For your Q19.3, you compiler is the same version. Right?

    • gwatcha's avatar
      gwatcha
      Icon for New Contributor rankNew Contributor

      yes my quartus version and hls version is the same, and they are both 19.1

      • gwatcha's avatar
        gwatcha
        Icon for New Contributor rankNew Contributor

        I tried not doing it my way and reverting the directory name change and following your suggestion. My resulting .bashrc looks like this:

        export PATH=$PATH:/home/michael/Program/intelFPGA/19.1/modelsim_ase/bin
        export QUARTUS_ROOTDIR=/home/michael/Program/intelFPGA/19.1
        export QSYS_ROOTDIR=/home/michael/Program/intelFPGA/19.1/quartus/sopc_builder/bin
        
        #GCC ENV for HLS
        export GCC_ROOTDIR=/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.7
        export PATH=$GCC_ROOTDIR:$PATH
        export LD_LIBRARY_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.7/lib:$LD_LIBRARY_PATH
        export CPLUS_INCLUDE_PATH=/home/michael/Program/intelFPGA/19.1/hls/include:/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.7/include
        export LIBRARY_PATH=/home/michael/Program/intelFPGA/19.1/hls/host/linux64/lib
        
        source /home/michael/Program/intelFPGA/19.1/hls/init_hls.sh
        

        Yet I still get some errors due to gcc 10.1 being included

        ╭─ ~/Program/intelFPGA/19.1/hls/examples/counter
        ╰─❯ bash
        Assuming current directory (/home/michael/Program/intelFPGA/19.1/hls) is root of i++
        
        Will use Quartus at /home/michael/Program/intelFPGA/19.1/hls/../quartus
        Will be using  Modelsim at /home/michael/Program/intelFPGA/19.1/modelsim_ase/bin
        Adding /home/michael/Program/intelFPGA/19.1/hls/bin to PATH
        Adding /home/michael/Program/intelFPGA/19.1/hls/host/linux64/lib to LD_LIBRARY_PATH
        [michael@zen counter]$ make
        No target specified, defaulting to test-x86-64
        Available targets: test-x86-64, test-fpga, test-gpp, clean
        i++ counter.cpp -I/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.7/include/c++ -I/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.7/include/c++/x86_64-pc-linux-gnu  -march=x86-64 -o test-x86-64
        In file included from counter.cpp:1:
        In file included from /home/michael/Program/intelFPGA/19.1/hls/include/HLS/hls.h:11:
        In file included from /home/michael/Program/intelFPGA/19.1/hls/include/HLS/hls_internal.h:10:
        In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/stdlib.h:36:
        /usr/lib/gcc/x86_64-pc-linux-gnu/4.4.7/include/c++/cstdlib:101:11: error: no member named 'div_t' in the global
              namespace
          using ::div_t;
                ~~^
        /usr/lib/gcc/x86_64-pc-linux-gnu/4.4.7/include/c++/cstdlib:102:11: error: no member named 'ldiv_t' in the global
              namespace
          using
        
        ...

        Now my work around is to put this into the Makefile for the counter example:

        CXXFLAGS := -I/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.7/include/c++ -I/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.7/include/c++/x86_64-pc-linux-gnu
        

        As well as changing the directory name:

        /usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0 -> /usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0_

        To fool the compiler.

        This fix dosen't get too far however, although `make test-x86-64` works, I get the following error when running `make test-fpga`

        # vsim -t ps "+nowarnTFMPC" -L work -L work_lib -L tb_count_internal_10 -L tb_altera_irq_mapper_191 -L tb_avalon_split_multibit_conduit_10 -L tb_hls_sim_main_dpi_controller_10 -L tb_count_10 -L tb_avalon_conduit_fanout_10 -L tb_avalon_concatenate_singlebit_conduits_10 -L tb_hls_sim_component_dpi_controller_10 -L tb_hls_sim_clock_reset_10 -L altera_ver -L lpm_ver -L sgate_ver -L altera_mf_ver -L altera_lnsim_ver -L twentynm_ver -L twentynm_hssi_ver -L twentynm_hip_ver -L altera -L lpm -L sgate -L altera_mf -L altera_lnsim -L twentynm -L twentynm_hssi -L twentynm_hip tb 
        # Start time: 12:01:41 on Jul 16,2020
        # ** Fatal: ** Error: (vsim-3827) Could not compile 'export_tramp.so': cmd = '/bin/gcc   -shared -fPIC -m32  -g  -I. -I"/home/michael/Program/intelFPGA/19.1/modelsim_ase/include" -I"/home/michael/Program/intelFPGA/19.1/modelsim_ase/../oem/include" -o "/tmp/michael@zen_dpi_29969/linuxpe_gcc-10.1.0/export_tramp.so" "/tmp/michael@zen_dpi_29969/linuxpe_gcc-10.1.0/export_tramp.S"'
        # (vsim-50) A call to system(/bin/gcc   -shared -fPIC -m32  -g  -I. -I"/home/michael/Program/intelFPGA/19.1/modelsim_ase/include" -I"/home/michael/Program/intelFPGA/19.1/modelsim_ase/../oem/include" -o "/tmp/michael@zen_dpi_29969/linuxpe_gcc-10.1.0/export_tramp.so" "/tmp/michael@zen_dpi_29969/linuxpe_gcc-10.1.0/export_tramp.S" >'/tmp/questatmp.775vJi' 2>&1) returned error code '1'.
        # The logfile contains the following messages:
        # gcc: fatal error: ‘-fuse-linker-plugin’, but liblto_plugin.so not found
        # compilation terminated.
        # 
        # No such file or directory. (errno = ENOENT)
        # 
        # 
        # FATAL ERROR while loading design
        # ** Error: Error loading design
        # Executing ONERROR command at macro ./tb/sim/mentor/msim_compile.tcl line 8
        

        And I believe this is because the fix dosen't fool `vsim` (you can see it is looking for something in gcc 10.1 and can't find it).

        So despite my fix, a proper solution would be nice.

        There must be some kind of environment variable to set to have it include files from the right directory, right?

  • KennyT_altera's avatar
    KennyT_altera
    Icon for Super Contributor rankSuper Contributor

    Will get back to you on this..

    Btw, I forgot to ask, what OS that you were using?

    • gwatcha's avatar
      gwatcha
      Icon for New Contributor rankNew Contributor

      Hey sorry I missed your message, I'm using Manjaro Linux.

  • KennyT_altera's avatar
    KennyT_altera
    Icon for Super Contributor rankSuper Contributor

    We do not receive any response from you to the previous question that we have provided. Please post a response in the next 15 days to allow me to continue to support you. After 15 days, this thread will be transitioned to community support. The community users will be able to help you with your follow-up questions.