Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using cmakeport to build ibmruntimes zoslib fails #22

Open
netskink opened this issue May 25, 2023 · 1 comment
Open

using cmakeport to build ibmruntimes zoslib fails #22

netskink opened this issue May 25, 2023 · 1 comment

Comments

@netskink
Copy link

Perhaps this should be here since I was using this version of cmake to build zoslib.

ibmruntimes/zoslib#21

@netskink
Copy link
Author

More investigation on this issue. At first, I thought this was a 2.4 versus 2.4.1 problem. I have /bin/xlclang 2.4.1 installed now. It is being used to build zoslib. With that said, here is what I found.

In CMake-heads.v3.24.2/share/cmake-3.24/Modules/CMakeTestCXXCompiler.cmake it is attempting to use file(WRITE ..) to write a file and then compile it as a test. I added a file(READ...) into a variable afterwards and then used message() to write that variable. The variable was blank. However, the file was created at some point. The file was just not written before the compiler test using try_compile().

I looked at the upstream stable tag v3.26.4 and the file() write mechanism was replaced with a compile sample written to a variable. Then the try_compile() routine used this variable for its source. Sadly this new parameter supporting SUPPORT_FROM_VAR is not in my current source. Its in the next stable version 3.25. See here.

With that said, I short-cut the code so it did not attempt to test the compiler to see if it would build zoslib. It did not.

-- Check for working C compiler: /bin/xlclang
-- Check for working C compiler: /bin/xlclang - broken
CMake Error at /z/jd895801/zopen/prod/CMake-heads.v3.24.2/share/cmake-3.24/Modules/CMakeTestCCompiler.cmake:69 (message):
  The C compiler

    "/bin/xlclang"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /z/jd895801/zopen/dev/try2/v8/third_party/zoslib/build/CMakeFiles/CMakeTmp

    Run Build Command(s):/z/jd895801/zopen/boot/make/bin/make -f Makefile cmTC_2ca09/fast && /z/jd895801/zopen/boot/make/bin/make  -f CMakeFiles/c
mTC_2ca09.dir/build.make CMakeFiles/cmTC_2ca09.dir/build
    make[1]: Entering directory '/z/jd895801/zopen/dev/try2/v8/third_party/zoslib/build/CMakeFiles/CMakeTmp'
    Building C object CMakeFiles/cmTC_2ca09.dir/testCCompiler.c.o
    /bin/xlclang    -o CMakeFiles/cmTC_2ca09.dir/testCCompiler.c.o -c /z/jd895801/zopen/dev/try2/v8/third_party/zoslib/build/CMakeFiles/CMakeTmp/testCCompiler.c
    Linking C executable cmTC_2ca09
    /z/jd895801/zopen/prod/CMake-heads.v3.24.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_2ca09.dir/link.txt --verbose=1
    /bin/xlclang CMakeFiles/cmTC_2ca09.dir/testCCompiler.c.o -o cmTC_2ca09
    FSUM3008 Specify a file with the correct suffix (.c, .i, .s, .o, .x, .p, .I, or .a), or a corresponding data set name, instead of -o./cmTC_2ca09.
    make[1]: *** [CMakeFiles/cmTC_2ca09.dir/build.make:99: cmTC_2ca09] Error 1
    make[1]: Leaving directory '/z/jd895801/zopen/dev/try2/v8/third_party/zoslib/build/CMakeFiles/CMakeTmp'
    make: *** [Makefile:127: cmTC_2ca09/fast] Error 2

Looking at the error above, when it tries to link, it uses the GNU gcc style. obj file and -o output file name. Attempting this
with xlclang...

$ xlclang testy.cxx -c -o testy.o
JD895801@USILCA31 ~
$ xlclang testy.o -o testy
FSUM3008 Specify a file with the correct suffix (.c, .i, .s, .o, .x, .p, .I, or .a), or a corresponding data set name, instead of -o./testy.
# reversing syntax
$ xlclang testy testy.o
$ ./testy 
Hello World

For reference, here is the notes and diff for the file write attempts.

@igortodorovski @mike fulton This is relative to the cmake failure with IBMRunTimes and Zos Open Tools zoslib

I'm currently using the IBMRunTimes version to build, and using the cmakeport for cmake. With that said, I don't have a diff of cmakeport since the install doesn't have a git repo. Instead, I have two dirs. The CMake-heads.v3.24.2 and the working CMake-heads.v3.24.2 (cmake.mods) install which I'm modifying.

$ mv CMake-heads.v3.24.2 cmake.mods
$ rm cmake
$ zopen install cmakeport
$ ln -s cmake cmake.mods

and the diff is:

--- CMake-heads.v3.24.2/share/cmake-3.24/Modules/CMakeTestCXXCompiler.cmake     2023-03-01 16:15:42 +0000
+++ cmake.mods/share/cmake-3.24/Modules/CMakeTestCXXCompiler.cmake      2023-06-30 11:15:00 +0000
@@ -38,16 +38,38 @@
 if(NOT CMAKE_CXX_COMPILER_WORKS)
   PrintTestCompilerStatus("CXX")
   TestCompiler_setTryCompileTargetType()
file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCXXCompiler.cxx
+  #file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCXXCompiler.cxx
+  #  "#ifndef cplusplus\n"
+  #  "# error "The CMAKE_CXX_COMPILER is set to a C compiler"\n"
+  #  "#endif\n"
+  #  "int main(){return 0;}\n")
+  # This works, but it seems to be delayed.  It is not there by the time, the READ or the try_compile
+  # routine runs.
+  #file(WRITE /z/jd895801/testy.cxx
+  #  "#ifndef cplusplus\n"
+  #  "# error "The CMAKE_CXX_COMPILER is set to a C compiler"\n"
+  #  "#endif\n"
+  #  "int main(){return 0;}\n")
+  file(GENERATE OUTPUT /z/jd895801/testy.cxx CONTENT
     "#ifndef cplusplus\n"
     "# error "The CMAKE_CXX_COMPILER is set to a C compiler"\n"
     "#endif\n" 
    "int main(){return 0;}\n")
+  message("-- Did we write a test file to check compiler?")
+  message("-- Did we write a test file to check compiler?")
+  file(READ /z/jd895801/testy.cc TESTY)
   # Clear result from normal variable.
   unset(CMAKE_CXX_COMPILER_WORKS)
   # Puts test result in cache variable.
+  message("yo yo yo")
+  message("CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
+  message("CMAKE_FILES__DIRECTORY: ${CMAKE_FILES_DIRECTORY}")
+  #message("FOO: ${FOO}")
+  message("TESTY: ${TESTY}")
+  message("yo yo yo")

And the invocation

$ cd ....zoslib
$ ./build.sh -c -r -s -t
...
-- Did we write a test file to check compiler?
CMake Error at /z/jd895801/zopen/prod/CMake-heads.v3.24.2/share/cmake-3.24/Modules/CMakeTestCXXCompiler.cmake:59 (file):
  file failed to open for reading (EDC5129I No such file or directory.):
>
    /z/jd895801/testy.cc
Call Stack (most recent call first):
  CMakeLists.txt:9 (project)
>
>
yo yo yo
CMAKE_BINARY_DIR: /z/jd895801/zopen/dev/try2/v8/third_party/zoslib/build
CMAKE_FILES__DIRECTORY: /CMakeFiles
TESTY:
yo yo yo
-- Check for working CXX compiler: /bin/xlclang++ - broken
....

The end result is that file(WRITE...) or file(GENERATE OUTPUT ...) both generate the test file in the file system, BUT not by the time, the file(READ...) or try_compile(..) routine occurs.

Any advice on what to do? I am thinking a newer version of cmake might fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant