nodejs / help

:sparkles: Need help with Node.js? File an Issue here. :rocket:
1.48k stars 284 forks source link

gyp and missing dependencies in .mk files #360

Closed sxa closed 7 years ago

sxa commented 8 years ago

I'm working on the shared library support for Node.js and I'm having a problem when I try to put in the support for AIX. We have an exports file that is generated in order to set which symbols are exported from the shared libary (or the node executable - this is the same in the main build).

In the executable case, we link node_main.cc into the final executable (it is linked along with various .a files which are produced during the build) using the node.exp file. So node_main.cc is comped alongside the node.exp, then the final link is done - I believe this resolves a race condition because the node.exp is generated faster than the time to compile node_main.cc.

In the shared library case when it doesn't compile node_main.cc, it appears that I am getting a failure as I cannot get a dependency correctly in place between node.exp and the final target in the generated .mk file. Here's the relevant fragment from my patch to the AIX section of the top level node.gyp file

         'conditions': [
            ['node_shared=="true"', {
              'target_name': 'libnode.<(node_module_version)',
              'type': 'shared_library',
            }, {
              'target_name': 'node',
              'type': 'executable',
              'sources': ['src/node_main.cc'],
            }],
          ],
          'dependencies': ['<(node_core_target_name)', 'node_exp'],

If I patch the .mk file between running configure and make to insert this dependency:

$(obj).target/libnode.51.a: $(obj).target/node_exp.stamp

Then it works because the correct dependency is in place. Without it I get:

  ld: 0706-004 Cannot find or read export file: /scratch/jenkins-local/new/workspace/ibmnode-master-sharedlib-unix/arch/ppc64/compiler/gcc48/label/build/os/aix/node/out/Release/node.exp
        ld:accessx(): A file or directory in the path name does not exist.
  collect2: error: ld returned 255 exit status

because it hasn't quite finished generating it before the link step happens. Anyone know what the trick I'm missing to force gyp to put that dependency, or something equivalent, into the generated makefile? I could just leave node_main.cc in the sources list (as the main symbol isn't exported it doesn't actually clash with anything linked against it) but that's not the sensible option ...

bnoordhuis commented 8 years ago

What happens when you add '<(PRODUCT_DIR)/node.exp' to 'sources'?

sxa commented 8 years ago

I tried that at one point in the past (and have verified it again this morning) - it appears to completely ignore it - the .mk file is the same as if it wasn't there. To clarify, this:

'sources': ['<(PRODUCT_DIR)/node.exp'], effectively acts as though that line wasn't there for the purposes of the .mk file and 'sources': ['<(PRODUCT_DIR)/node.exp','src/node_main.cc'],

adds in the extra stuff to the OBJS definition in the .mk file with node_main.o. I tried experimenting a little with the stuff in make.py in the gyp directory, but no luck so far getting it to do what I want.

If I can't find a way of getting it in I might just submit it with the node_main.cc included at least for now - alternatively I could include some dummy C file in the shared library. The way I've been building up til now is to build it, get the error, remove the libnode file and then run make again which generates it properly, but that's obviously not acceptable.

Knighton910 commented 7 years ago

Closing for now, but if still need help with this, reopen & we will take it from there.