[Openmp-dev] Initial Intel Cmake Build System Patch

Peyton, Jonathan L jonathan.l.peyton at intel.com
Mon Jun 9 14:21:38 PDT 2014


Jack,

I have had this problem before.  For some reason, specifying the compiler(s) for consecutive runs of cmake is no good.
From http://www.cmake.org/Wiki/CMake_Useful_Variables
CMAKE_C_COMPILER
the compiler used for C files. Normally it is detected and set during the CMake run, but you can override it at configuration time. Note! It cannot be changed after the first cmake or ccmake run. Although the gui allows to enter an alternative, it will be ignored in the next 'configure' run. Use for

It has to go like this:
% cd openmp/runtime
% mkdir build
% cd build
% cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -Darch=32 ..
...
% make
...
% cmake -Darch=32e ..
...
% make

Or this (adding rm –rf command):
% cd openmp/runtime
% mkdir build
% cd build
% cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -Darch=32 ..
...
% make
...
% rm –rf *
% cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++  -Darch=32e ..
...
% make

I’m not sure why it messes up so badly when specifying the compiler again.  It appears from the messages below that it thinks the objects from the previous IA-32 build are up to date.

Something else you can try  is this (32e build first, 32 build second):
% cd openmp/runtime
% mkdir build
% cd build
% cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -Darch=32e ..
...
% make
...
% cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++  -Darch=32 ..
...

Your –Darch=32 will be ignored!  And the final configuration will show 32e.
The moral of the story: Only specify the compiler for the first run of cmake in a given build directory, or clean out the build directory for each cmake run.

Johnny


From: Jack Howarth [mailto:howarth.mailing.lists at gmail.com]
Sent: Monday, June 9, 2014 2:50 PM
To: Peyton, Jonathan L
Cc: openmp-dev at dcs-maillist2.engr.illinois.edu
Subject: Re: [Openmp-dev] Initial Intel Cmake Build System Patch

Jonathan,
     This doesn't seem to work for me on darwin12…

% cd openmp/runtime
% mkdir build
% cd build
% cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -Darch=32 ..
...
% make
...
% cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -Darch=32e ..
...
% make
Scanning dependencies of target inc
[  0%] Generating ../exports/mac_32e/include_compat/iomp_lib.h
[  5%] Built target inc
Scanning dependencies of target needed-headers
[ 15%] Built target needed-headers
Scanning dependencies of target lib
[ 15%] Generating kmp_dummy.o
[ 21%] Generating external-objects.lst
warning: nm: no name list
[ 21%] Generating external-symbols.lst
[ 21%] Generating iomp.o
ld: warning: ld: warning: ld: warning: ignoring file kmp_version.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_version.oignoring file kmp_ftn_extra.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_ftn_extra.oignoring file kmp_ftn_cdecl.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_ftn_cdecl.o


ld: warning: ignoring file kmp_alloc.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_alloc.o
ld: warning: ld: warning: ignoring file kmp_atomic.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_atomic.oignoring file kmp_csupport.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_csupport.o
ld: warning:
ignoring file kmp_debug.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_debug.o
ld: warning: ld: warning: ld: warning: ignoring file kmp_itt.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_itt.oignoring file kmp_error.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_error.old: warning: ignoring file kmp_environment.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_environment.o

ignoring file kmp_global.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_global.o
ld: warning:
ignoring file kmp_i18n.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_i18n.old: warning:
ignoring file kmp_io.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_io.old: warning: ld: warning:
ignoring file kmp_settings.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_settings.oignoring file kmp_runtime.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_runtime.o
ld: warning:
ignoring file kmp_str.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_str.o
ld: warning: ignoring file kmp_tasking.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_tasking.o
ld: warning: ignoring file kmp_taskq.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_taskq.o
ld: warning: ld: warning: ignoring file kmp_threadprivate.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_threadprivate.oignoring file kmp_utility.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_utility.old: warning:

ignoring file ittnotify_static.o, file was built for i386 which is not the architecture being linked (x86_64): ittnotify_static.old: warning: ld: warning: ld: warning: ld: warning:
ld: warning: ignoring file z_Linux_util.o, file was built for i386 which is not the architecture being linked (x86_64): z_Linux_util.old: warning: ignoring file kmp_gsupport.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_gsupport.old: warning: ignoring file kmp_affinity.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_affinity.oignoring file kmp_dispatch.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_dispatch.oignoring file kmp_sched.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_sched.o
ignoring file kmp_lock.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_lock.old: warning:
ignoring file kmp_taskdeps.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_taskdeps.o



ignoring file kmp_cancel.o, file was built for i386 which is not the architecture being linked (x86_64): kmp_cancel.old: warning:

ignoring file z_Linux_asm.o, file was built for i386 which is not the architecture being linked (x86_64): z_Linux_asm.o
[ 26%] Generating unstripped/libiomp5.dylib
[ 26%] Generating libiomp5.dylib
[ 31%] Generating test-touch-rt/.success
Undefined symbols for architecture x86_64:
  "_omp_get_max_threads", referenced from:
      _main in test-touch-a2b314.o
  "_omp_get_num_threads", referenced from:
      _main in test-touch-a2b314.o
  "_omp_get_wtime", referenced from:
      _main in test-touch-a2b314.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [test-touch-rt/.success] Error 1
make[1]: *** [CMakeFiles/lib.dir/all] Error 2

You need to execute a limited form of make clean in between the two build the would delete the previous object files but not the previously built shared libraries. Does this already exist in the cmake support but is undocumented?
                         Jack

On Mon, Jun 9, 2014 at 11:14 AM, Peyton, Jonathan L <jonathan.l.peyton at intel.com<mailto:jonathan.l.peyton at intel.com>> wrote:
Jack,

Right now, after you build the both the 32 and 32e libraries, you should be able to say “make fat” and it will call the lipo command for you.
Keep in mind, the system is setup so that cmake will only include the “fat” target when the configuration is for 32e, and it will not automatically build the libraries for you if you specify the “fat” target but both 32 and 32e libraries haven’t been built yet, only an error is spit out.  There are no plans to automate it further.

There is some instruction on it in Build_With_CMake.txt.
+Mac Fat Libraries
+=================
+On OS X machines, it is possible to build universal (or fat) libraries which
+include both IA-32 architecture and Intel(R) 64 architecture objects in a
+single archive; just build the 32 and 32e libraries separately:
+ $ cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -Darch=32 ..
+ $ make
+ $ cmake -Darch=32e ..
+ $ make
+then invoke make again with a special argument as follows:
+ $ make fat
+* The fat target is only available for the arch=32e configuration.
+* The fat libraries will be put in exports/mac_32e/lib while the "thin" libraries
+  will be in exports/mac_32e/lib.thin and exports/mac_32/lib.thin

Johnny

From: Jack Howarth [mailto:howarth.mailing.lists at gmail.com<mailto:howarth.mailing.lists at gmail.com>]
Sent: Friday, June 6, 2014 8:42 PM
To: Peyton, Jonathan L
Cc: openmp-dev at dcs-maillist2.engr.illinois.edu<mailto:openmp-dev at dcs-maillist2.engr.illinois.edu>
Subject: Re: [Openmp-dev] Initial Intel Cmake Build System Patch

Jonathon,
     Thanks. Confirmed to work properly on x86_64-apple-darwin12 with…

% cd runtime
% mkdir build
% cd build
% cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -Dos=mac -Darch=32 ..
% make all common
% file libiomp5.dylib
libiomp5.dylib: Mach-O dynamically linked shared library i386

and

% cd runtime
% mkdir build
% cd build
% cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -Dos=mac -Darch=32e ..
% make all common
% file libiomp5.dylib
libiomp5.dylib: Mach-O 64-bit dynamically linked shared library x86_64

Are there any plans to tweak this to automate the build of a fat libiomp5.dylib on darwin?


On Fri, Jun 6, 2014 at 7:02 PM, Peyton, Jonathan L <jonathan.l.peyton at intel.com<mailto:jonathan.l.peyton at intel.com>> wrote:
Hello All,

Since everyone wants to see it, this patch is the initial cmake build system we have been developing.  Some quick notes:
1) The top-level CMakeLists.txt you all have been working on is moved to CMakeLists.txt.old (the src/CMakeLists.txt file is untouched)
2) There is a Build_With_CMake.txt tutorial that shows the most important features and how to build libiomp5
3) As a special note, the current build.pl<http://build.pl> system does five “micro-tests” which test certain features of the newly built libiomp5.so library (basic linking/compilation, library dependencies, etc.)  If you want these to be off in the new CMake system just specify it when calling cmake with the flag –Dtests=off

Please keep in mind this is the initial system and that it can be trimmed back incrementally to what you need.  Right now, it builds nearly identical libraries as build.pl<http://build.pl>.  On a related note, I attempted ( as suggested by David ) to port libiomp5 to NetBSD to see what walls I would hit.  I hit some ☺ , but eventually got it working (not included in this initial patch).  So I am going to follow up this initial patch with further improvements (to the build system) to make re-targeting in general even easier.  Some of these improvements will also help the build.pl<http://build.pl> system as well.

Just try it.  See what you hate and what you like.  Leave feedback.  I am here on weekdays.

Thanks,
Johnny

_______________________________________________
Openmp-dev mailing list
Openmp-dev at dcs-maillist2.engr.illinois.edu<mailto:Openmp-dev at dcs-maillist2.engr.illinois.edu>
http://lists.cs.uiuc.edu/mailman/listinfo/openmp-dev


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/openmp-dev/attachments/20140609/1dce8624/attachment.html>


More information about the Openmp-dev mailing list