Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved] What does "patch does not fit" mean?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
jasn
Guru
Guru


Joined: 05 May 2005
Posts: 439
Location: Maryland, US

PostPosted: Sat Jul 28, 2012 3:37 pm    Post subject: [Solved] What does "patch does not fit" mean? Reply with quote

I'm trying to patch dev-lang/rubinius-1.2.4.20110705 so that it will install on my system with sys-devel/llvm-3.1-r1. Based on the bug discussion thread here, it was pointed out that a commit was done to support llvm3.1, here. Using this tip, I was able to download the commit as a patch, and then attempted to apply it using localpatch. However the patch failed with an error message that I've seen before when I've tried to apply a patch that I've found under similar circumstances;
Quote:
Local patch rubinius-1.2.4.20110705-llvm-3.1.patch does not fit.

So what does this error message actually mean? How does a patch not fit? Is there something I'm doing wrong when trying to apply this kind of patch? For completeness, here's the patch as I downloaded it and tried to apply it;
Code:
From 629c5925cc44b2384060d6cc14d1a52b27db5779 Mon Sep 17 00:00:00 2001
From: Dirkjan Bussink
Date: Sun, 10 Jun 2012 13:18:26 +0200
Subject: [PATCH] Support LLVM 3.1

---
 Rakefile                 |    2 +-
 configure                |   15 +++++++++------
 vm/llvm/disassembler.cpp |   29 ++++++++++++++++++++++++++++-
 vm/llvm/disassembler.hpp |    5 +++++
 vm/llvm/state.cpp        |   15 ++++++++++++++-
 5 files changed, 57 insertions(+), 9 deletions(-)

diff --git a/Rakefile b/Rakefile
index ee42647..b4f34fe 100644
--- a/Rakefile
+++ b/Rakefile
@@ -33,7 +33,7 @@ end
 require config_rb
 BUILD_CONFIG = Rubinius::BUILD_CONFIG
 
-unless BUILD_CONFIG[:config_version] == 156
+unless BUILD_CONFIG[:config_version] == 157
   STDERR.puts "Your configuration is outdated, please run ./configure first"
   exit 1
 end
diff --git a/configure b/configure
index 848d0f7..077c0bc 100755
--- a/configure
+++ b/configure
@@ -124,7 +124,7 @@ class Configure
     @libversion = "2.0"
     @version = "#{@libversion}.0dev"
     @release_date = "yyyy-mm-dd"
-    @config_version = 156
+    @config_version = 157
 
     # TODO: add conditionals for platforms
     if RbConfig::CONFIG["build_os"] =~ /darwin/
@@ -622,7 +622,9 @@ Unsupported language version requested: #{ver}. Options are #{@supported_version
     if File.directory?("#{@llvm_default}/Release")
       config = llvm_config_cmd "#{@llvm_default}/Release/bin/llvm-config"
       version = `#{config} --version`.strip
-      if version == "3.0"
+      parts = version.sub(/svn$/, "").split(".").map { |i| i.to_i }
+      api_version = ("%d%02d" % parts[0..1]).to_i
+      if version >= "3.0"
         # See if this has rtti turned off and reject it.
         if `#{config} --cxxflags`.index("-fno-rtti")
           @log.write "incorrectly configure (rtti is off)"
@@ -634,8 +636,9 @@ Unsupported language version requested: #{ver}. Options are #{@supported_version
           else
             @llvm = :prebuilt
           end
-
-          @llvm_configure = config
+          @llvm_version     = version
+          @llvm_api_version = api_version
+          @llvm_configure   = config
           return
         end
       else
@@ -682,8 +685,8 @@ Unsupported language version requested: #{ver}. Options are #{@supported_version
       api_version = ("%d%02d" % parts[0..1]).to_i
       if `#{llvm_config_cmd config} --cxxflags`.index("-fno-rtti")
         @log.write "incorrectly configured llvm (rtti is off)"
-      elsif api_version != 300
-        @log.write "only LLVM 3.0 is supported"
+      elsif api_version < 300
+        @log.write "only LLVM 3.x is supported"
       else
         @log.write "found! (version #{version} - api: #{api_version})"
         @llvm = :config
diff --git a/vm/llvm/disassembler.cpp b/vm/llvm/disassembler.cpp
index 8a2e42a..4f241c4 100644
--- a/vm/llvm/disassembler.cpp
+++ b/vm/llvm/disassembler.cpp
@@ -26,15 +26,37 @@
   , disassembler(0)
   , memory_object(0)
   {
+#if RBX_LLVM_API_VER > 300
+    std::string host = llvm::sys::getDefaultTargetTriple();
+#else
     std::string host = llvm::sys::getHostTriple();
+#endif
     std::string error;
     llvm::InitializeNativeTargetAsmPrinter();
+#if RBX_LLVM_API_VER > 300
+    llvm::InitializeNativeTargetDisassembler();
+#else
     llvm::InitializeAllDisassemblers();
+#endif
     target = llvm::TargetRegistry::lookupTarget(host, error);
+
+#if RBX_LLVM_API_VER > 300
+    llvm::TargetOptions options;
+    options.NoFramePointerElim = true;
+    options.NoFramePointerElimNonLeaf = true;
+    target_machine = target->createTargetMachine(host, llvm::sys::getHostCPUName(), "", options);
+#else
     target_machine = target->createTargetMachine(host, llvm::sys::getHostCPUName(), "");
+#endif
 
     sub_target = target->createMCSubtargetInfo(host, llvm::sys::getHostCPUName(), "");
     asm_info = target->createMCAsmInfo(host);
+
+#if RBX_LLVM_API_VER > 300
+    instr_info = target->createMCInstrInfo();
+    reg_info = target->createMCRegInfo(host);
+#endif
+
     if(asm_info) {
       disassembler = target->createMCDisassembler(*sub_target);
       memory_object = new JITMemoryObject((const uint8_t*)buffer, (uint64_t) size);
@@ -58,7 +80,12 @@
     }
 
     llvm::MCInstPrinter* printer = target->createMCInstPrinter(
-                                   asm_info->getAssemblerDialect(), *asm_info, *sub_target);
+                                   asm_info->getAssemblerDialect(), *asm_info,
+#if RBX_LLVM_API_VER > 300
+                                   *instr_info,
+                                   *reg_info,
+#endif
+                                   *sub_target);
     if(!printer) {
       return std::string("No instruction printer for target");
     }
diff --git a/vm/llvm/disassembler.hpp b/vm/llvm/disassembler.hpp
index a4ba2b5..aedf27a 100644
--- a/vm/llvm/disassembler.hpp
+++ b/vm/llvm/disassembler.hpp
@@ -75,6 +75,11 @@
       const llvm::TargetMachine* target_machine;
       const llvm::MCSubtargetInfo* sub_target;
       const llvm::MCAsmInfo* asm_info;
+#if RBX_LLVM_API_VER > 300
+      const llvm::MCInstrInfo* instr_info;
+      const llvm::MCRegisterInfo* reg_info;
+#endif
+
       llvm::MCDisassembler* disassembler;
       const JITMemoryObject* memory_object;
   };
diff --git a/vm/llvm/state.cpp b/vm/llvm/state.cpp
index 60a3067..00f7f14 100644
--- a/vm/llvm/state.cpp
+++ b/vm/llvm/state.cpp
@@ -504,7 +504,9 @@
       }
     }
 
+#if RBX_LLVM_API_VER <= 300
     llvm::NoFramePointerElim = true;
+#endif
     llvm::InitializeNativeTarget();
 
     VoidTy = Type::getVoidTy(ctx_);
@@ -537,7 +539,18 @@
 
     autogen_types::makeLLVMModuleContents(module_);
 
-    engine_ = ExecutionEngine::create(module_, false, 0, CodeGenOpt::Default, false);
+    llvm::EngineBuilder factory(module_);
+    factory.setAllocateGVsWithCode(false);
+
+#if RBX_LLVM_API_VER > 300
+    llvm::TargetOptions opts;
+    opts.NoFramePointerElim = true;
+    opts.NoFramePointerElimNonLeaf = true;
+
+    factory.setTargetOptions(opts);
+#endif
+
+    engine_ = factory.create();
 
     passes_ = new llvm::FunctionPassManager(module_);
 
--
1.7.10


Thanks..


Last edited by jasn on Sun Jul 29, 2012 2:45 pm; edited 3 times in total
Back to top
View user's profile Send private message
dol-sen
Retired Dev
Retired Dev


Joined: 30 Jun 2002
Posts: 2805
Location: Richmond, BC, Canada

PostPosted: Sat Jul 28, 2012 4:00 pm    Post subject: Reply with quote

I'm not an expert at this, but... Looks like you need to loose the header portion.

Code:
From 629c5925cc44b2384060d6cc14d1a52b27db5779 Mon Sep 17 00:00:00 2001
From: Dirkjan Bussink <d.bussink@gmail.com>
Date: Sun, 10 Jun 2012 13:18:26 +0200
Subject: [PATCH] Support LLVM 3.1

---
 Rakefile                 |    2 +-
 configure                |   15 +++++++++------
 vm/llvm/disassembler.cpp |   29 ++++++++++++++++++++++++++++-
 vm/llvm/disassembler.hpp |    5 +++++
 vm/llvm/state.cpp        |   15 ++++++++++++++-
 5 files changed, 57 insertions(+), 9 deletions(-)


Then edit the file paths, example:
Code:
--- a/Rakefile
+++ b/Rakefile
to match the paths starting in the workdir, not the "/var/tmp/portage/..." portion. Editing those paths is something I have had to do to make patches work in ebuilds.
_________________
Brian
Porthole, the Portage GUI frontend irc@freenode: #gentoo-guis, #porthole, Blog
layman, gentoolkit, CoreBuilder, esearch...
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21633

PostPosted: Sat Jul 28, 2012 4:05 pm    Post subject: Reply with quote

GNU patch should handle the posted file as-is, assuming that it is relevant to the targeted code. OP: could you post the context around the error message and explain exactly how you set up the patch to apply? That does not look like the message that Portage would use if you were using /etc/portage/patches. Please show the exact shell commands that one of us would execute to recreate your changes.
Back to top
View user's profile Send private message
jasn
Guru
Guru


Joined: 05 May 2005
Posts: 439
Location: Maryland, US

PostPosted: Sat Jul 28, 2012 4:39 pm    Post subject: Reply with quote

After downloading the patch, I renamed it to
Code:
rubinius-1.2.4.20110705-llvm-3.1.patch

and placed it in the following directory;
Code:
/etc/portage/patches/dev-lang/rubinius-1.2.4.20110705

I then try to emerge rubinius which results in the following short output;
Code:
emerge -v rubinius

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N     ] dev-lang/rubinius-1.2.4.20110705  0 kB

Total: 1 package (1 new), Size of downloads: 0 kB

>>> Verifying ebuild manifests
>>> Emerging (1 of 1) dev-lang/rubinius-1.2.4.20110705
>>> Failed to emerge dev-lang/rubinius-1.2.4.20110705, Log file:
>>>  '/var/log/portage/dev-lang:rubinius-1.2.4.20110705:20120728-163623.log'
>>> Jobs: 0 of 1 complete, 1 failed                 Load avg: 0.24, 0.16, 0.09
 * Package:    dev-lang/rubinius-1.2.4.20110705
 * Repository: gentoo
 * Maintainer: ruby@gentoo.org
 * USE:        amd64 elibc_glibc kernel_linux multilib userland_GNU
 * FEATURES:   preserve-libs sandbox splitdebug
>>> cfg-update-1.8.2-r1: Checksum index is up-to-date ...
>>> Unpacking source...
>>> Unpacking rubinius-1.2.4-20110705.tar.gz to /tmp/portage/dev-lang/rubinius-1.2.4.20110705/work
>>> Source unpacked in /tmp/portage/dev-lang/rubinius-1.2.4.20110705/work
>>> Preparing source in /tmp/portage/dev-lang/rubinius-1.2.4.20110705/work/rubinius-1.2.4 ...
 * QA Notice: The 'hasq' function is deprecated (replaced by 'has')
 * Local patch rubinius-1.2.4.20110705-llvm-3.1.patch does not fit.
 [ !! ]
 * ERROR: dev-lang/rubinius-1.2.4.20110705 failed (prepare phase):
 *   localpatch failed.
 *
 * Call stack:
 *            ebuild.sh, line 708:  Called ebuild_main 'prepare'
 *   phase-functions.sh, line 996:  Called dyn_prepare
 *   phase-functions.sh, line 419:  Called localpatch
 *          environment, line 1814:  Called die
 * The specific snippet of code:
 *                               die "localpatch failed.";
 *
 * If you need support, post the output of `emerge --info '=dev-lang/rubinius-1.2.4.20110705'`,
 * the complete build log and the output of `emerge -pqv '=dev-lang/rubinius-1.2.4.20110705'`.
 * The complete build log is located at '/var/log/portage/dev-lang:rubinius-1.2.4.20110705:20120728-163623.log'.
 * For convenience, a symlink to the build log is located at '/tmp/portage/dev-lang/rubinius-1.2.4.20110705/temp/build.log'.
 * The ebuild environment file is located at '/tmp/portage/dev-lang/rubinius-1.2.4.20110705/temp/environment'.
 * Working directory: '/tmp/portage/dev-lang/rubinius-1.2.4.20110705/work/rubinius-1.2.4'
 * S: '/tmp/portage/dev-lang/rubinius-1.2.4.20110705/work/rubinius-1.2.4'

Here is my emerge --info
Code:
emerge --info '=dev-lang/rubinius-1.2.4.20110705'
Portage 2.3.4-r7 (funtoo/1.0/linux-gnu/arch/x86-64bit, gcc-4.6.2, glibc-2.13-r4, 3.5.0-gentoo x86_64)
=================================================================
                        System Settings
=================================================================
System uname: Linux-3.5.0-gentoo-x86_64-Intel-R-_Core-TM-_i7-2820QM_CPU_@_2.30GHz-with-gentoo-2.2.0
Timestamp of tree: Sat, 28 Jul 2012 06:00:01 +0000
app-shells/bash:          4.2_p24
dev-java/java-config:     2.1.12-r1000
dev-lang/python:          2.7.3-r1000, 3.2.3-r1000
dev-util/cmake:           2.8.8-r3
sys-apps/baselayout:      2.2.0-r1
sys-apps/openrc:          0.10.2-r3
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.13, 2.69
sys-devel/automake:       1.4_p6-r1, 1.9.6-r3, 1.10.3, 1.11.6
sys-devel/binutils:       2.21.1-r1
sys-devel/gcc:            4.6.2-r1
sys-devel/gcc-config:     1.5
sys-devel/libtool:        2.4.2
sys-devel/make:           3.82-r3
sys-kernel/linux-headers: 3.3 (virtual/os-headers)
sys-libs/glibc:           2.13-r4
Repositories: gentoo multimedia sunrise gamerlay-stable gnome java-overlay local
ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /usr/share/themes/oxygen-gtk/gtk-2.0 /var/lib/hsqldb"
CONFIG_PROTECT_MASK="${EPREFIX}/etc/gconf /etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.4/ext-active/ /etc/php/cgi-php5.4/ext-active/ /etc/php/cli-php5.4/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c /etc/udev/rules.d"
CXXFLAGS="-march=native -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--jobs=8 --load-average=8 --with-bdeps y --autounmask-write y"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles fixpackages localpatch news parallel-fetch parallel-install parse-eapi-ebuild-head preserve-libs protect-owned sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS=""
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--as-needed"
LINGUAS="en en_US"
MAKEOPTS="-j9 -l8"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_TMPDIR="/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/multimedia /var/lib/layman/sunrise /var/lib/layman/gamerlay /var/lib/layman/gnome /var/lib/layman/java-overlay /usr/local/portage"
SYNC="git://github.com/funtoo/ports-2012.git"
SYNC_USER="root"
USE="64bit X a52 aac aacs acl acpi alsa amd64 apache2 apcupsd applet archive artworkextra aspell audio avahi bash-completion berkdb bluetooth bluray branding bzip2 cairo calendar cdaudio cdda cddb cdr cheese clutter colord consolekit corefonts cracklib crypt css cups curl cxx dbus dia dirac divx djvu dri dri2 dts dv dvb dvd dvdr dvdread eds encode esd evo examples exceptions exif faac faad ffmpeg flac gallium gconf gdbm gif gimp git glade glitz gnome gnome-keyring gnome-online-accounts google gphoto2 gpm graphicsmagick graphviz grilo gstreamer gtk gtk3 h323 hddtemp html hunspell iconv icu id3 id3tag ieee1394 imagemagick inotify introspection ipod ipv6 jabber java javascript jpeg jpeg2k jpg lame laptop latex lcdfilter lcms libcanberra libv4l libv4l2 libvisual llvm lm_sensors lock lyrics lzo mad map mariadb matroska mjpeg mkfont mmx mng modules mp3 mp4 mpeg mplayer mudflap multilib musepack musicbrainz mysql nautilus ncurses networkmanager nfs nls nntp nptl nsplugin nss ntfs ntp ocr ogg ogm opengl openmp openssl pam pcre pdf perl pidgin pm-utils png podcast policykit ppds pppd projectm pulseaudio python qt3support qt4 quicktime rar readline realmedia rss rtf samba sane scanner schroedinger sdl session sip sndfile socialweb sox speex spell sse sse2 sse3 sse4_1 sse4_2 ssl ssse3 startup-notification subversion svg tcl tcpd telepathy templates theora threads tiff tivo tk tracker truetype udev unicode upnp usb v4l v4l2 video virtualbox vlc vorbis vpx wav wavpack webcam webkit webm wifi wmf wmp x264 xcb xcomposite xfce xfs xine xml xmp xmpp xorg xscreensaver xulrunner xv xvid xvmc youtube zeroconf zip zlib" ALSA_CARDS="hda-intel" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump" CAMERAS="canon" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="evdev keyboard mouse synaptics wacom" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en en_US" PHP_TARGETS="php5-3" PYTHON_ABIS="2.7 3.2" PYTHON_TARGETS="python2_7" QEMU_SOFTMMU_TARGETS="i386 x86_64" QEMU_USER_TARGETS="i386 x86_64" RUBY_TARGETS="ruby18 ruby19" USERLAND="GNU" VIDEO_CARDS="r600" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, SYNC_UMASK

Thanks..
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Sat Jul 28, 2012 5:56 pm    Post subject: Reply with quote

jasn ...

how are we to know what changes funtoo has made to the epatch_user() function in the eutils.eclass or other indeed other eclasses and portage in general? The error message doesn't seem to be present in the epatch_user() function at least on gentoo. So, your asking in the wrong forum ... I suggest you try funtoo forums.

best ... khay
Back to top
View user's profile Send private message
jasn
Guru
Guru


Joined: 05 May 2005
Posts: 439
Location: Maryland, US

PostPosted: Sat Jul 28, 2012 6:02 pm    Post subject: Reply with quote

After some prompting from posting this over on the Funtoo forums, it appears that the patch doesn't work correctly against the dev-lang/rubinius-1.2.4.20110705 source. I should have looked at this more closely before posting, because after examining the patch and source, I see that the patch attempts to patch three files that don't even exist in the dev-lang/rubinius-1.2.4.20110705 source, vm/llvm/disassembler.cpp, vm/llvm/disassembler.hpp, and vm/llvm/state.cpp. Perhaps that's what generates the error message of the "patch does not fit".

Because it was raised as a possible factor, I wanted to repost to the thread and report that this issue doesn't appear to be Gentoo/Funtoo "difference related". My original question was just asking what the, "does not fit" error message meant, because it isn't very informative. I got the same error message when I applied the patch via my local overlay. However, I was able to see the actual patch output error message after manually attempting to apply the patch.

Thanks..
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum