View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0011782CMakeCMakepublic2011-02-01 10:592011-03-28 12:28
ReporterBrian Panneton 
Assigned ToMathieu Malaterre 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformLinuxOSCentOSOS Version2.16.0
Product VersionCMake 2.8.3 
Target VersionFixed in Version 
Summary0011782: Issue with UseSWIG.cmake and parallel builds
DescriptionI have found an issue with UseSWIG.cmake during parallel builds. If you are swigging Python and Java using the SWIG_ADD_MODULE and SWIG_LINK_LIBRARIES macros you could run into this issue.

When you run through CMake, the macro SWIG_GET_EXTRA_OUTPUT_FILES sets the variable SWIG_EXTRA_GENERATED_FILES. This variable is used by a custom command as an output. When CMaking, it never gets reset. Thus if you start with swigging Python, the file module.py is appended to it. Then when swigging Java, the same file remains as an output.

If you are running in parallel, the output file is claimed by both Java and Python. Somehow this makes it so the Python lib might not get fully built on the first try.

To solve this issue on the user side we need to reset SWIG_EXTRA_GENERATED_FILES right before you call the macro SWIG_ADD_MODULE, like such:

set(swig_extra_generated_files "")
swig_add_module(${module_name} python module.i)

To solve this issue on the UseSWIG.cmake side add SET(${outfiles} "") to the first line of the macro SWIG_GET_EXTRA_OUTPUT_FILES, like such:

MACRO(SWIG_GET_EXTRA_OUTPUT_FILES language outfiles generatedpath infile)
  SET(${outfiles} "")
  GET_SOURCE_FILE_PROPERTY(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename
    ${infile} SWIG_MODULE_NAME)

I am pretty sure this would solve the issue. Please let me know if this is the correct way to go about it.

Thanks,
Brian Panneton
TagsNo tags attached.
Attached Filestar file icon test.tar [^] (184,320 bytes) 2011-02-03 12:47

 Relationships

  Notes
(0025244)
Brian Panneton (reporter)
2011-02-03 12:49

I have uploaded a tarball of a simple test that shows the issue. I am using CMake 2.8.3, SWIG 2.0.0, Python 2.6.4, and Java JDK6. Unpack it and just run "cmake ." to see ${swig_extra_generated_files} before and after each swigging. Either of the above solutions fix this.
(0025936)
Mathieu Malaterre (developer)
2011-03-28 12:28

$ git push stage HEAD
Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 402 bytes, done.
Total 4 (delta 3), reused 0 (delta 0)
To git@cmake.org:stage/cmake.git
 * [new branch] HEAD -> fixbug_0011782

 Issue History
Date Modified Username Field Change
2011-02-01 10:59 Brian Panneton New Issue
2011-02-01 11:01 Mathieu Malaterre Assigned To => Mathieu Malaterre
2011-02-01 11:01 Mathieu Malaterre Status new => assigned
2011-02-03 12:47 Brian Panneton File Added: test.tar
2011-02-03 12:49 Brian Panneton Note Added: 0025244
2011-03-28 12:28 Mathieu Malaterre Note Added: 0025936
2011-03-28 12:28 Mathieu Malaterre Status assigned => closed
2011-03-28 12:28 Mathieu Malaterre Resolution open => fixed


Copyright © 2000 - 2018 MantisBT Team