IBM / ibmi-oss-issues

Important resources for anyone interested in open source on IBM i
Creative Commons Zero v1.0 Universal
13 stars 0 forks source link

Node-Gyp: Fails to compile any modules including bCrypt or ODBC - sigset_t #41

Closed mattseaboard closed 10 months ago

mattseaboard commented 10 months ago

Problem

Upon upgrading our IBM i OS from 7.4 to 7.5, compilation of any C++-based Node.js module downloaded from NPM started failing, including bcrypt and odbc packages. This causes the NPM package installation to fail which renders the Node.js application inoperable.

Verification

Cause

A recent update of the GCC packages on yum for IBM i added a definition of the sigset_t struct to the /usr/include/sys/time.h file. This definition was not previously present here. Along with that, the /QOpenSys/pkgs/lib/gcc/powerpc-ibm-aix6.1.0.0/6.3.0/include-fixed-7.1/sys/types.h file defines sigset_t without first checking if sigset_t has already been defined.

As a result, if the /usr/include/sys/time.h file is processed by the compiler before the /QOpenSys/pkgs/lib/gcc/powerpc-ibm-aix6.1.0.0/6.3.0/include-fixed-7.1/sys/types.h file, there will be a duplicate definition of sigset_t and the compilation will fail.

Resolution

The simplest way to resolve this issue is to update the /QOpenSys/pkgs/lib/gcc/powerpc-ibm-aix6.1.0.0/6.3.0/include-fixed-7.1/sys/types.h file to only define the sigset_t struct if it has not already been defined. This can be accomplished by surrounding the sigset_t definition lines in a ifndef condition which will only pass if sigset_t has not already been defined.

The following diff can be applied to the file to make this change:

344a345,346

ifndef _SIGSET_T

define _SIGSET_T

361a364

endif / _SIGSET_T /

Once that file has been changed, try the npm install again and it should be able to successfully install this time.

kadler commented 10 months ago

Yep, this is a known issue and a duplicate of #27.

Unfortunately, we don't have much ability to fix GCC 6 due to the way we package it from the prebuilt AIX rpms. Please use GCC 10 instead by eg. CC=gcc-10 CXX=g++-10 npm i

mattseaboard commented 10 months ago

Thanks @kadler. I don't quite understand your instructions there. Is this just a bash command I need to run? Do I need to uninstall GCC 6?

Also, do you know what is causing this error upon upgrading to IBM i 7.5? I was informed that the upgrade itself did not modify any open source packages.

kadler commented 10 months ago

Yes, this is just part of the npm command you run. You can export the CC and CXX environment variables in bash or prefix them to your npm command.

The problem is that GCC needs to modify some system header files in order to work correctly and the modified versions it ships are not compatible with the updated IBM i 7.5 system header files. The GCC 10 rpms we have are built by us and we handle the modified system header files differently. There, the rpm runs a tool which modifies the system header files from the system it's installed on instead of shipping a pre-modified copy.

mattseaboard commented 10 months ago

I appreciate you taking the time to explain to me so I can relay this info on to our IBM i admin. Have a good one!